Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/215.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android OneSignal-Can';t单击通知打开已关闭的应用程序_Android_Onesignal - Fatal编程技术网

Android OneSignal-Can';t单击通知打开已关闭的应用程序

Android OneSignal-Can';t单击通知打开已关闭的应用程序,android,onesignal,Android,Onesignal,我无法通过单击OneSignal中的通知打开我的应用程序。应用程序关闭时不会发生任何事情;只有当我在应用程序(打开)中时,它才起作用。我没有收到任何日志错误。我做错了什么?任何帮助都会很好,我被困在这上面了 public class OneSignalPushApplication extends Application{ @Override public void onCreate() { super.onCreate(); // Loggin

我无法通过单击OneSignal中的通知打开我的应用程序。应用程序关闭时不会发生任何事情;只有当我在应用程序(打开)中时,它才起作用。我没有收到任何日志错误。我做错了什么?任何帮助都会很好,我被困在这上面了

public class OneSignalPushApplication extends Application{
    @Override
    public void onCreate() {
        super.onCreate();

        // Logging set to help debug issues, remove before releasing your app.
        //OneSignal.setLogLevel(OneSignal.LOG_LEVEL.VERBOSE, OneSignal.LOG_LEVEL.WARN);

        OneSignal.startInit(this)
                .setNotificationOpenedHandler(new ExampleNotificationOpenedHandler())
                .inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification)
                .autoPromptLocation(true)
                .init();
    }

    private class ExampleNotificationOpenedHandler implements OneSignal.NotificationOpenedHandler {
        // This fires when a notification is opened by tapping on it.
        @Override
        public void notificationOpened(OSNotificationOpenResult result) {

            String title=result.notification.payload.title;
            String desc=result.notification.payload.body;

            Log.d("xiomi", "Received Title "+title);
            Log.d("xiomi", "Received Desc "+desc);


            Intent intent = new Intent(getApplicationContext(), Intro.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.putExtra("push_title", title);
            intent.putExtra("push_message", desc);
            startActivity(intent);

        }
    }
}
My
Intro
最终调用
MainActivity
的调用:

public class Intro extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getIntent().setAction("Already created");
        String title = getIntent().getStringExtra("title");
        Toast.makeText(this, title , Toast.LENGTH_LONG).show();



                EasySplashScreen config = new EasySplashScreen(Intro.this)
                        .withFullScreen()
                        .withTargetActivity(MainActivity.class)
                        .withSplashTimeOut(2000)
                        .withBackgroundResource(R.drawable.spash);


                View easySplashScreenView = config.create();
                setContentView(easySplashScreenView);


        }



    @Override
    protected void onResume() {
       // Log.v("Resume", "onResume");
        super.onResume();
    }

}
应用程序清单:

<application ...>
   <meta-data android:name="com.onesignal.NotificationOpened.DEFAULT" android:value="DISABLE" />
</application>

通过在清单上的应用程序标记中添加OneSignalPushApplication类解决

<application
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:name=".OneSignalPushApplication"
        android:theme="@style/AppTheme">


参考此链接@MohammadAli仍然无法打开日志中的任何错误???@ALTegani yeaa我在日志中没有发现任何错误这是奇怪的部分