11package jp .studyplus .android .sdk .example ;
22
33import android .app .Activity ;
4+ import android .content .ActivityNotFoundException ;
45import android .content .Context ;
56import android .content .Intent ;
67import android .os .Bundle ;
1617import jp .studyplus .android .sdk .service .api .StudyplusApi ;
1718import jp .studyplus .android .sdk .service .api .response .ErrorResponse ;
1819import jp .studyplus .android .sdk .service .api .response .SuccessfulResponse ;
20+ import jp .studyplus .android .sdk .service .auth .AccessTokenNotFound ;
1921import jp .studyplus .android .sdk .service .auth .AuthTransit ;
2022import jp .studyplus .android .sdk .service .auth .CertificationStore ;
2123import jp .studyplus .android .sdk .service .studyrecord .StudyRecordBuilder ;
@@ -57,7 +59,13 @@ public void onClick(View v) {
5759 .setDurationSeconds (2 * 60 )
5860 .build ());
5961
60- StudyplusApi .getClient (context ).send (request .with (this ));
62+ try {
63+ StudyplusApi .getClient (context ).send (request .with (this ));
64+ } catch (AccessTokenNotFound e ) {
65+ e .printStackTrace ();
66+ Toast .makeText (context , R .string . sample_certification_no_access_token , Toast .LENGTH_SHORT )
67+ .show ();
68+ }
6169 }
6270
6371 @ Subscribe
@@ -84,10 +92,16 @@ private OnClickToAuth(Activity activity) {
8492 }
8593 @ Override
8694 public void onClick (View v ) {
87- AuthTransit .from (activity ).startActivity (
88- context .getString (R .string .sample_consumer_key ),
89- context .getString (R .string .sample_consumer_key_secret )
90- );
95+ try {
96+ AuthTransit .from (activity ).startActivity (
97+ context .getString (R .string .sample_consumer_key ),
98+ context .getString (R .string .sample_consumer_key_secret )
99+ );
100+ } catch (ActivityNotFoundException e ) {
101+ e .printStackTrace ();
102+ Toast .makeText (context , R .string .sample_certification_studyplus_not_found , Toast .LENGTH_SHORT )
103+ .show ();
104+ }
91105 }
92106 }
93107
0 commit comments