IBM Mobilefirst:当我点击通知时,App会重新启动 [英] IBM Mobilefirst : App gets restarted when I click on the Notification

查看:99
本文介绍了IBM Mobilefirst:当我点击通知时,App会重新启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发MFP Integrated的android原生应用程序。
我已经实现了MFP推送通知,并且工作正常。我收到通知。但是当我点击通知我的应用程序重新启动。实际的问题是我有一个启动活动,在我的应用程序启动时启动,并在其中初始化我的所有MFP内容并杀死此应用程序以登录活动。



在我的清单文件中,我将接收器定义为如下。

 < activity 
android:name =SplashActivity
android:theme =@ style / AppTheme.NoActionBar>
< intent-filter>

< category android:name =android.intent.category.LAUNCHER/>
< / intent-filter>
< intent-filter>
< category android:name =android.intent.category.DEFAULT/>
< / intent-filter>
< / activity>

接收者是在我的飞溅活动中定义的,但我正在完成此活动并开始登录活动,然后从登录到其他活动。现在,每次启动应用程序时,只会调用一次splash动作。



因为这个原因当我点击通知时,它会杀死其他活动并再次启动splash活动,因为它被询问只能在飞溅活动中接收。



那么有人可以告诉我如何设计我的应用程序,以便在应用程序的任何活动中收到通知(它不应该启动飞溅活动,而应该在应用程序打开的同一活动中,并调用onrecieve消息方法)。



请建议。



之前我已经问过类似的问题,但可能会发现问题,因此我将这个问题发布到实际问题中寻求解决方案。
Mobilefirst PushNotification:在服务器上使用wl_anonymousUserRealm时,应用程序不会在点击通知时调用onReceive方法 我得到了一些解决方案。



我已经创建了一个虚拟活动,并将上面提到的代码绑定到它。

<$
android:name =。controllers.activities.DummyActivity
android:launchMode =singleTask
android:theme =@ code>< activity
android:风格/ AppTheme.NoActionBar>


< category android:name =android.intent.category.DEFAULT/>
< / intent-filter>
< / activity>

如果我的应用程序在后台并且应用程序收到通知。点击通知后,它会打开虚拟活动,我在onResume()中调用finish()方法。所以这个特殊的活动甚至在它被打开之前就会被完成,这将打开前面的活动,并且如果它是假的,我将支票说成applaunched,我正在重新启动应用程序。



<这不是一个直接的解决方案,但现在是一种解决方法。


I am developing android native app with MFP Integrated. I have Implemented MFP push notification and it works fine. I get the notification. But when I click the notification my app restarts.

The actual issue was I have a splash activity which is launched on my app launch and where I am initializing all my MFP stuff and killing this activity taking the app to login activity.

And in My manifest file I am defining my receiver as below.

<activity
            android:name="SplashActivity"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
            <action android:name="com.mypackage.app_name.NOTIFICATION" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        </activity>

The receiver is defined in my splash activity but I am finishing this activity and going to login activity and then from login to other activities . Now splash activity is only called once in every app launch.

For this reason When I click on notification it is killing the other activities and launching splash activity again because it is asked to receive only in splash activity.

So can some body tell me how do I design my app so that I can receive the notification when I am on any activity of the app(It should not launch the splash activity but instead it should be on the same activity the app is open, and call the onrecieve message method)..

Please suggest.

I have asked a similar type of question before but could find the problem then, so I am posting this question with actual problem asking for solution. Mobilefirst PushNotification: On using wl_anonymousUserRealm at server, app is not calling onReceive method on clicking notification

解决方案

Finally i got some solution.

I have created a dummy activity and binding the above mention code to it.`

<activity
    android:name=".controllers.activities.DummyActivity"
    android:launchMode="singleTask"
    android:theme="@style/AppTheme.NoActionBar">


    <intent-filter>
        <action android:name="com.mypackage.NOTIFICATION" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>

If my app is in background and app gets a notification . On clicking of Notification it will open the dummyactivity and i am calling finish() method in the onResume(). So this particular activity will be finished even before it is opened which will open the pervious activity and I am putting a check saying applaunched if it is false, I am relaunching the app.

This cant be a straight solution but it is a work around for now.

这篇关于IBM Mobilefirst:当我点击通知时,App会重新启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆