Android Studioを使用してSamsung Gear Fitダイアログを作成します。このコード ブロックに問題があります。mListView で .setAdapter を使用すると失敗するようです。初期化時に demo_list を mListView に渡すと、警告が表示されます。したがって、この demo_list には何か問題がある可能性があります。私はAndroidが初めてなので、いくつかのことがわかりません。私が使用しているコード ベースには、いくつかのレイアウト ファイルがあります。リスト ビューを root_layout.xml に配置すると、root_layout でリストを定義すると demo_list を参照するエラーが消えますが、他のレイアウト ファイルでも消えます。
したがって、問題は、demo_list を定義した場合でも、setAdapter を使用するとアプリが初期ロード時にクラッシュすることです。また、ブレーク ポイントを配置してデバッグを実行すると、findViewById メソッドに循環ロジックが発生します。
Samsung Gear Fit (CUP SDK) http://forum.xda-developers.com/gear-fit/development/samsung-gear-fit-sdk-available-t2872803
私のレポは https://github.com/jackygrahamez/MayDayです
HomeActivity.java のコード ブロック
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, NAMES);
ListView mListView = (ListView) findViewById(R.id.demo_list);
mListView.setAdapter(adapter);
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// S Pen SDK Demo programs
if (position == MAYDAY_CUP) {
if (mHelloCupDialog == null) {
mHelloCupDialog = new GearFitDialog(getApplicationContext());
} else {
mHelloCupDialog.finish();
mHelloCupDialog = null;
}
}
}
});
ログキャット
02-07 15:11:39.059 11358-11358/com.mayday.md I/SELinux﹕ Function: selinux_android_load_priority [0], There is no sepolicy file.
02-07 15:11:39.079 11358-11358/com.mayday.md I/SELinux﹕ Function: selinux_android_load_priority , spota verifySig and checkHash pass. priority version is VE=SEPF_SM-G900T_4.4.2_0034
02-07 15:11:39.079 11358-11358/com.mayday.md I/SELinux﹕ selinux_android_seapp_context_reload: seapp_contexts file is loaded from /data/security/spota/seapp_contexts
02-07 15:11:39.079 11358-11358/com.mayday.md E/dalvikvm﹕ >>>>> Normal User
02-07 15:11:39.079 11358-11358/com.mayday.md E/dalvikvm﹕ >>>>> com.mayday.md [ userId:0 | appId:10430 ]
02-07 15:11:39.079 11358-11358/com.mayday.md D/dalvikvm﹕ Late-enabling CheckJNI
02-07 15:11:39.319 11358-11358/com.mayday.md I/PersonaManager﹕ getPersonaService() name persona_policy
02-07 15:11:39.359 11358-11358/com.mayday.md I/PersonaManager﹕ getPersonaService() name persona_policy
02-07 15:11:39.399 11358-11358/com.mayday.md D/skia﹕ GFXPNG PNG bitmap created width:720 height:1280 bitmap id is 270
02-07 15:11:39.429 11358-11358/com.mayday.md I/dalvikvm-heap﹕ Grow heap (frag case) to 28.360MB for 8294416-byte allocation
02-07 15:11:39.449 11358-11358/com.mayday.md D/AndroidRuntime﹕ Shutting down VM
02-07 15:11:39.449 11358-11358/com.mayday.md W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41742da0)
02-07 15:11:39.449 11358-11358/com.mayday.md E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.mayday.md, PID: 11358
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mayday.md/com.mayday.md.HomeActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2395)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2453)
at android.app.ActivityThread.access$900(ActivityThread.java:173)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5579)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.mayday.md.HomeActivity.onCreate(HomeActivity.java:62)
at android.app.Activity.performCreate(Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2359)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2453)
at android.app.ActivityThread.access$900(ActivityThread.java:173)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5579)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
02-07 15:11:44.829 11358-11358/com.mayday.md I/Process﹕ Sending signal. PID: 11358 SIG: 9
02-07 15:12:29.939 12336-12336/com.mayday.md I/SELinux﹕ Function: selinux_android_load_priority [0], There is no sepolicy file.
02-07 15:12:29.949 12336-12336/com.mayday.md I/SELinux﹕ Function: selinux_android_load_priority , spota verifySig and checkHash pass. priority version is VE=SEPF_SM-G900T_4.4.2_0034
02-07 15:12:29.949 12336-12336/com.mayday.md I/SELinux﹕ selinux_android_seapp_context_reload: seapp_contexts file is loaded from /data/security/spota/seapp_contexts
02-07 15:12:29.959 12336-12336/com.mayday.md E/dalvikvm﹕ >>>>> Normal User
02-07 15:12:29.959 12336-12336/com.mayday.md E/dalvikvm﹕ >>>>> com.mayday.md [ userId:0 | appId:10431 ]
02-07 15:12:29.959 12336-12336/com.mayday.md D/dalvikvm﹕ Late-enabling CheckJNI
02-07 15:12:30.259 12336-12336/com.mayday.md I/PersonaManager﹕ getPersonaService() name persona_policy
02-07 15:12:30.309 12336-12336/com.mayday.md I/PersonaManager﹕ getPersonaService() name persona_policy
02-07 15:12:30.339 12336-12336/com.mayday.md D/skia﹕ GFXPNG PNG bitmap created width:720 height:1280 bitmap id is 270
02-07 15:12:30.349 12336-12336/com.mayday.md I/dalvikvm-heap﹕ Grow heap (frag case) to 28.354MB for 8294416-byte allocation
02-07 15:12:30.369 12336-12336/com.mayday.md D/AndroidRuntime﹕ Shutting down VM
02-07 15:12:30.369 12336-12336/com.mayday.md W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41742da0)
02-07 15:12:30.379 12336-12336/com.mayday.md E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.mayday.md, PID: 12336
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mayday.md/com.mayday.md.HomeActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2395)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2453)
at android.app.ActivityThread.access$900(ActivityThread.java:173)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5579)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.mayday.md.HomeActivity.onCreate(HomeActivity.java:62)
at android.app.Activity.performCreate(Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2359)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2453)
at android.app.ActivityThread.access$900(ActivityThread.java:173)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5579)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
02-07 15:12:33.289 12336-12336/com.mayday.md I/Process﹕ Sending signal. PID: 12336 SIG: 9