简体   繁体   English

三星CUP sdk对话框示例出现问题

[英]Trouble with the Samsung CUP sdk dialog example

Using Android Studio to build a Samsung Gear Fit Dialog. 使用Android Studio构建Samsung Gear Fit对话框。 I have an issue with this block of code. 我对这段代码有疑问。 It seems to fail when I mListView uses the .setAdapter. 当我的mListView使用.setAdapter时,它似乎失败了。 There is a warning when I pass the demo_list into the mListView on initialization. 在初始化时将demo_list传递到mListView时,会出现警告。 So something may be wrong with this demo_list. 因此,此demo_list可能有问题。 I'm new to android so I'm not sure about a few things. 我是android的新手,所以我不确定几件事。 The code base I am using has several layout files. 我使用的代码库有几个布局文件。 I put the list view in the root_layout.xml the error referencing the demo_list goes away when I define the list in root_layout but it also goes away in other layout files. 我将列表视图放在root_layout.xml中,当我在root_layout中定义列表时,引用demo_list的错误消失了,但在其他布局文件中也消失了。

So the problem is even when I define the demo_list the app crashes on initial load app crashes when using the setAdapter. 因此,问题就算是当我定义demo_list时,使用setAdapter时应用程序也会在初始加载时崩溃。 Also when I put a break point and run it through debug there is circular logic in the findViewById method. 同样,当我放置一个断点并通过调试运行它时,findViewById方法中存在循环逻辑。

Samsung Gear Fit (CUP SDK) http://forum.xda-developers.com/gear-fit/development/samsung-gear-fit-sdk-available-t2872803 三星Gear Fit(CUP SDK) http://forum.xda-developers.com/gear-fit/development/samsung-gear-fit-sdk-available-t2872803

My repo is https://github.com/jackygrahamez/MayDay 我的仓库是https://github.com/jackygrahamez/MayDay

My code block in HomeActivity.java 我在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;
                }
            }
        }
    });

Logcat logcat的

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

Based on the error logcat, and go through your HomeActivity 'onCreate()', I see that your codes: 基于错误logcat,并通过HomeActivity'onCreate()',我看到您的代码:

setContentView(R.layout.welcome_screen);

and:

ListView mListView = (ListView) findViewById(R.id.demo_list);

however, there is no ListView 'R.id.demo_list' in your layout 'welcome_screen.xml', instead ListView 'R.id.demo_list' is defined in your layout 'fragment_type_simple.xml'. 但是,在布局'welcome_screen.xml'中没有ListView'R.id.demo_list',而是在布局'fragment_type_simple.xml'中定义了ListView'R.id.demo_list'。

So if layout 'fragment_type_simple.xml' is your HomeActivity UI, then you should replace: 因此,如果布局“ fragment_type_simple.xml”是您的HomeActivity UI,则应替换:

setContentView(R.layout.welcome_screen);
with:
setContentView(R.layout.fragment_type_simple);

otherwise you should add ListView with id 'demo_list' in your layout 'welcome_screen.xml'. 否则,应在布局“ welcome_screen.xml”中添加ID为“ demo_list”的ListView。

Hope this is clear! 希望这很清楚!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM