简体   繁体   English

Android:android.content.res.Resources $ NotFoundException:字符串资源ID

[英]Android: android.content.res.Resources$NotFoundException: String resource ID

I created an class to use Google Analytics, I added functions but I get an error to access to this string: ProductAction.ACTION_PURCHASE, error code: 我创建了一个使用Google Analytics(分析)的类,添加了函数,但访问此字符串时出现错误:ProductAction.ACTION_PUR​​CHASE,错误代码:

  08-19 08:50:14.944  16673-16947/fr.solutis.solutis E/AndroidRuntime﹕
  FATAL EXCEPTION: AsyncTask #1
 Process: fr.solutis.solutis, PID: 16673
 java.lang.RuntimeException: An error occured while executing doInBackground()
         at android.os.AsyncTask$3.done(AsyncTask.java:300)
         at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
         at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
         at java.util.concurrent.FutureTask.run(FutureTask.java:242)
         at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
         at java.lang.Thread.run(Thread.java:841)
  Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f08003a
         at android.content.res.Resources.getText(Resources.java:244)
         at android.content.res.Resources.getString(Resources.java:330)
         at fr.solutis.solutis.GoogleAnalytics.envoieTracker(GoogleAnalytics.java:38)
         at fr.solutis.solutis.DemandeGratuite$AsyncSoapCall.doInBackground(DemandeGratuite.java:1932)
         at fr.solutis.solutis.DemandeGratuite$AsyncSoapCall.doInBackground(DemandeGratuite.java:1915)
         at android.os.AsyncTask$2.call(AsyncTask.java:288)
         at java.util.concurrent.FutureTask.run(FutureTask.java:237)
         at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
         at java.lang.Thread.run(Thread.java:841)

GoogleAnalytics.java: GoogleAnalytics.java:

public class GoogleAnalytics{


    private Context context;
    public GoogleAnalytics(Context context) {
        this.context = context;
    }


    public void envoieTracker(String idApplication, int demandeId, String logement, String typeForm){

        DatabaseHandler db = new DatabaseHandler(context);

        String id = idApplication + demandeId;

        //if (code.equals("1")) {
            db.updateStatutDateEnvoie(demandeId);
            Product product = new Product()
                    .setId(id)
                    .setName(logement)
                    .setCategory(typeForm)
                    .setBrand("")
                    .setVariant("")
                    .setPrice(1)
                    .setCouponCode("")
                    .setQuantity(1);
            ProductAction productAction = new ProductAction(ProductAction.ACTION_PURCHASE)
                    .setTransactionId(id)
                    .setTransactionAffiliation(Resources.getSystem().getString(R.string.TransactionAffiliation))
                    .setTransactionRevenue(1)
                    .setTransactionTax(0)
                    .setTransactionShipping(0)
                    .setTransactionCouponCode("");
            HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder()
                    .addProduct(product)
                    .setProductAction(productAction);

            App app = new App();
            Tracker t = app.getTracker();
            t.setScreenName("Demande");
            t.send(builder.build());
        //}
    }
}

How I call it from my fragment: 我如何从片段中调用它:

            GoogleAnalytics ga= new GoogleAnalytics(getActivity());
            ga.envoieTracker(idApplication, demandeId, logement, typeForm);

Replace 更换

Resources.getSystem().getString(R.string.TransactionAffiliation)

to

context.getResources().getString(R.string.TransactionAffiliation)

暂无
暂无

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

相关问题 android.content.res.Resources$NotFoundException · 字符串资源 ID # - android.content.res.Resources$NotFoundException · String resource ID # android.content.res.Resources$NotFoundException:字符串资源 ID - android.content.res.Resources$NotFoundException: String resource ID android.content.res.resources notfoundexception $ android.content.res.resources notfoundexception $字符串资源ID#0x1 - android.content.res.resources notfoundexception $android.content.res.resources notfoundexception $ string resource id #0x1 android.content.res.Resources $ NotFoundException:资源ID#0xffffffff - android.content.res.Resources$NotFoundException: Resource ID #0xffffffff android.content.res.Resources $ NotFoundException:资源ID#0x0 - android.content.res.Resources$NotFoundException: Resource ID #0x0 android.content.res.Resources $ NotFoundException:资源ID#0x0 - android.content.res.Resources$NotFoundException: Resource ID #0x0 android.content.res.Resources $ NotFoundException:无法找到资源ID - android.content.res.Resources$NotFoundException: Unable to find resource ID 缺少资源 ID android.content.res.Resources$NotFoundException:字符串资源 ID #0xb - missing resource id android.content.res.Resources$NotFoundException: String resource ID #0xb Android:android.content.res.Resources$NotFoundException:字符串资源 ID #0x5 - Android: android.content.res.Resources$NotFoundException: String resource ID #0x5 带错误android.content.res.Resources $ NotFoundException的sqlite适配器:字符串资源ID#0xa - sqlite adapter with error android.content.res.Resources$NotFoundException: String resource ID #0xa
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM