File tree Expand file tree Collapse file tree 4 files changed +24
-9
lines changed
java/jp/studyplus/android/sdk/example
StudyplusAndroidSDK/src/main/java/jp/studyplus/android/sdk/service/auth Expand file tree Collapse file tree 4 files changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -28,10 +28,15 @@ dependencies {
28
28
Open an Activity to connect with Studyplus.
29
29
30
30
``` java
31
- AuthTransit . from(activity). startActivity(
32
- context. getString(" app_consumer_key" ),
33
- context. getString(" app_consumer_key_secret" )
34
- );
31
+ try {
32
+ AuthTransit . from(activity). startActivity(
33
+ context. getString(" app_consumer_key" ),
34
+ context. getString(" app_consumer_key_secret" )
35
+ );
36
+ } catch (ActivityNotFoundException e) {
37
+ e. printStackTrace();
38
+ Toast . makeText(context, " Need for Studyplus 2.14.0+" , Toast . LENGTH_SHORT ). show();
39
+ }
35
40
```
36
41
37
42
Then save its result.
Original file line number Diff line number Diff line change 1
1
package jp .studyplus .android .sdk .example ;
2
2
3
3
import android .app .Activity ;
4
+ import android .content .ActivityNotFoundException ;
4
5
import android .content .Context ;
5
6
import android .content .Intent ;
6
7
import android .os .Bundle ;
@@ -84,10 +85,16 @@ private OnClickToAuth(Activity activity) {
84
85
}
85
86
@ Override
86
87
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
- );
88
+ try {
89
+ AuthTransit .from (activity ).startActivity (
90
+ context .getString (R .string .sample_consumer_key ),
91
+ context .getString (R .string .sample_consumer_key_secret )
92
+ );
93
+ } catch (ActivityNotFoundException e ) {
94
+ e .printStackTrace ();
95
+ Toast .makeText (context , R .string .sample_certification_studyplus_not_found , Toast .LENGTH_SHORT )
96
+ .show ();
97
+ }
91
98
}
92
99
}
93
100
Original file line number Diff line number Diff line change 4
4
<string name =" app_name" >SDK Example</string >
5
5
<string name =" hello_world" >Hello world!!!</string >
6
6
7
+ <string name =" sample_certification_studyplus_not_found" >Studyplus 2.14.0 以上のインストールが必要です。</string >
7
8
</resources >
Original file line number Diff line number Diff line change 1
1
package jp .studyplus .android .sdk .service .auth ;
2
2
3
3
import android .app .Activity ;
4
+ import android .content .ActivityNotFoundException ;
4
5
import android .content .Intent ;
5
6
import android .net .Uri ;
6
7
@@ -24,7 +25,8 @@ public AuthTransit setRequestCode(int requestCode){
24
25
return new AuthTransit (activity , requestCode );
25
26
}
26
27
27
- public void startActivity (String consumerKey , String consumerSecret ){
28
+ public void startActivity (String consumerKey , String consumerSecret )
29
+ throws ActivityNotFoundException {
28
30
Intent intent = new Intent ();
29
31
intent .setAction (Intent .ACTION_VIEW );
30
32
intent .putExtra ("consumer_key" , consumerKey );
You can’t perform that action at this time.
0 commit comments