簡體   English   中英

缺少資源 ID android.content.res.Resources$NotFoundException:字符串資源 ID #0xb

[英]missing resource id android.content.res.Resources$NotFoundException: String resource ID #0xb

我的應用程序在移動到下一個活動時崩潰,並出現錯誤 android.content.res.Resources$NotFoundException: String resource ID #0xb。 我是新手,但如果你能提供幫助我會很高興

日志貓

2020-04-21 19:29:39.538 11528-11528/com.twlapps.lumicliosurveys E/lumicliosurvey:無效 ID 0x0000000b。 2020-04-21 19:29:39.562 11528-11528/com.twlapps.lumicliosurveys E/AndroidRuntime: FATAL EXCEPTION: main Process: com.twlapps.lumicliosurveys, PID: 11528 java.lang.RuntimeException: Unable to start activity ComponentInfo{ com.twlapps.lumicliosurveys/com.twlapps.lumicliosurveys.HomeActivity}: android.content.res.Resources$NotFoundException: String resource ID #0xb at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3344) at android.app. ActivityThread.handleLaunchActivity(ActivityThread.java:3488) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.Z93F725A07423FE1C 889F448B33D21F46Z:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2049) at android.os.Handler.dispatchMessage(Handler.java :106) at android.os.Looper.loop(Looper.java:216) at android.app.ActivityThread.main(ActivityThread.java:7506) at java.lang.reflect.Method.invoke(Native Method) at com. android。

活動

        profilecard.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (haveinternet()) {
                String profile = "yes";

                Intent profilesurveys = new Intent(HomeActivity.this, SurveysActivity.class);
                profilesurveys.putExtra("profile",profile);
                startActivity(profilesurveys);
                finish();
            } else if (!haveinternet()) {
                Toast.makeText(HomeActivity.this,"No internet Connection", Toast.LENGTH_LONG).show();
            }
        }
    });

    Calendar cal = Calendar.getInstance();
    if (Calendar.HOUR_OF_DAY >= 4 && Calendar.HOUR < 12 ){
        Toast.makeText(HomeActivity.this,String.valueOf(Calendar.HOUR_OF_DAY), Toast.LENGTH_LONG).show();
        gettime.setText("Good Morning, How was your night?");
    }else  if (Calendar.HOUR_OF_DAY >= 23 && Calendar.HOUR_OF_DAY < 4 ) {
        gettime.setText("Good Night, Have a nice sleep!");
    }else if (Calendar.HOUR_OF_DAY >= 18 && Calendar.HOUR_OF_DAY < 23 ) {
        gettime.setText("Good Evening, How was your day?");
    }else if (Calendar.HOUR_OF_DAY >= 12 && Calendar.HOUR_OF_DAY < 18 ) {
        gettime.setText("Good Afternoon!");
    }


    if (haveinternet()) {
        String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();

        DocumentReference documentReference = firebaseFirestore.collection("USERS").document(uid);
        documentReference.addSnapshotListener(this, new EventListener<DocumentSnapshot>() {
            @Override
            public void onEvent(@Nullable DocumentSnapshot documentSnapshot, @Nullable FirebaseFirestoreException e) {
                if (documentSnapshot.exists()) {
                    String profilechek = documentSnapshot.getString("profile");
                    if (profilechek.equals("false")){
                        profileimgcheck.setVisibility(View.INVISIBLE);
                    }else if (profilechek.equals("true")){
                        profileimgcheck.setVisibility(View.VISIBLE);
                    }
                    String othercheck = documentSnapshot.getString("others");
                    if (othercheck.equals("false")){
                        othersimgcheck.setVisibility(View.INVISIBLE);
                    }else if (othercheck.equals("true")){
                        othersimgcheck.setVisibility(View.VISIBLE);
                    }
                    String followceck = documentSnapshot.getString("followtwitter");
                    if (followceck.equals("false")){
                        followcheck.setVisibility(View.INVISIBLE);
                    }else if (followceck.equals("true")){
                        followcheck.setVisibility(View.VISIBLE);
                    }

                    getYourName.setText(documentSnapshot.getString("fullname"));
                    getYourMoney.setText(String.valueOf(documentSnapshot.getString("Amount")));

                }else {
                    Toast.makeText(HomeActivity.this,"An error occurred... Try again or contact support", Toast.LENGTH_LONG).show();
                }
            }
        });

請問我能做什么?

我沒有看到整個活動,但根據您發布的日志和代碼,問題可能出在

String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();

getUid() 可能會給您一個 integer 並且您將其分配給一個字符串值。

看起來你還沒有在 AndroidManifesto 文件中注冊你的活動。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM