Skip to content Skip to sidebar Skip to footer

Startactivity() Does Nothing Even When The Intent Is Specified Correctly

I am trying to open an activity from the launcher activity when an FCM-generated notification gets clicked. The startActivity function does nothing even when the log statement writ

Solution 1:

Try Adding android:exported="true" to the activity in AndroidManifest.xml

Solution 2:

First finish Login activity, and then call start activity.

LoginActivity.this.finish();
LoginActivity.this.startActivity(intent);

Solution 3:

In your manifest, define your class which you want to open like this

<activityandroid:name=".activities.ApprovalDetailActivity"android:exported="true"android:screenOrientation="portrait"android:theme="@style/MyMaterialTheme"android:windowSoftInputMode="stateHidden"><intent-filter><actionandroid:name="android.intent.action.VIEW" /><categoryandroid:name="android.intent.category.DEFAULT" /></intent-filter></activity>

Solution 4:

Nothing works for me except this one. The thing work for me is simple. Make sure you add this in the activity that you want to open directly.

<intent-filter><actionandroid:name="MainActivity" /><categoryandroid:name="android.intent.category.DEFAULT" /></intent-filter>

And from the push notification you must add a new payload: click_action it will looks like this -

"notification":{"title":"hello","body":"test message","click_action":"MAIN_ACTIVITY"},

Note: You can name it as you want MAIN_ACTIVITY but must be same in both place.

Post a Comment for "Startactivity() Does Nothing Even When The Intent Is Specified Correctly"