简体   繁体   English

Android 应用内评论弹出窗口使应用崩溃

[英]Android In-app Review pop-up crashes the app

Trying to implement the in-app Review for Android I had no problem running the test FakeReviewManager as commented below, but when swapping it out with the real manager I get a crash as the window should pop up.尝试为 Android 实现应用内审核时,我运行测试 FakeReviewManager 没有问题,如下所述,但是当将其与真正的管理器交换时,我会崩溃,因为窗口应该弹出。 This is the code I have:这是我的代码:

ReviewManager manager;
ReviewInfo reviewInfo;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //manager = new FakeReviewManager(context);
    manager = ReviewManagerFactory.create(this);
    Task<ReviewInfo> request = manager.requestReviewFlow();
    request.addOnCompleteListener(task -> {
        if (task.isSuccessful()) {
            Log.d("myTag","Review can be requested");
            ReviewInfo reviewInfo = task.getResult();
        } else {
            // There was some problem, continue regardless of the result.
        }
    });
}

public void ProgressManagement() {

     Task<Void> flow = manager.launchReviewFlow(MainActivity.this, reviewInfo);
     flow.addOnCompleteListener(task -> {
     Log.d("myTag","Review process completed");
     });
}

This is the error code I get:这是我得到的错误代码:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.android, PID: 16579
java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.PendingIntent com.google.android.play.core.review.ReviewInfo.a()' on a null object reference
    at com.google.android.play.core.review.c.launchReviewFlow(Unknown Source:7)
    at com.android.MainActivity.ProgressManagement(MainActivity.java:280)
    at com.android.MainActivity$4.onClick(MainActivity.java:209)
    at android.view.View.performClick(View.java:6897)
    at android.view.View$PerformClick.run(View.java:26104)
    at android.os.Handler.handleCallback(Handler.java:789)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6944)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

Try this:尝试这个:

add the following添加以下内容

private ReviewInfo reviewInfo;

below以下

ReviewManager manager;

and then change this:然后改变这个:

if (task.isSuccessful()) {
        Log.d("myTag","Review can be requested");
        ReviewInfo reviewInfo = task.getResult();
    }

to this:对此:

if (task.isSuccessful()) {
        Log.d("myTag","Review can be requested");
        reviewInfo = task.getResult();
    }

Looks like you didn't initialize ui.看起来你没有初始化ui。 setContentView() is absent. setContentView() 不存在。

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

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