App not resuming when clicking notification - android

I have integrated FCM into my app using react-native-firebase
When I background my app and receive a Push Notification, I want my app to resume from the background state.
It appears the onCreate() function from MainActivity is being called because I can see my SplashScreen.
Here's my AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="myapp">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:name=".MainApplication"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="#style/AppTheme">
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/notification_icon" />
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<!-- Background Messages (Optional) -->
<service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" />
</application>
</manifest>

Set launchMode in your activity to avoid notifications from creating a new Activity instance.
Set launchMode of your SplashScreen to singleInstance.
Refer: https://developer.android.com/guide/topics/manifest/activity-element.html#lmode

Related

Android Wear Authorization not Working

I created an app for the Wear operating system.
I used Android Studio 3.1.3
In this app I inserted a button and on the click of this I would like the watch to vibrate.
The problem is that the permissions of the app do not work.
I entered the request for vibration permission in the manifest, but when I start the app on the clock does not require me permissions and if I check the permissions registered for the app tells me that no authorization is required.
where am I wrong?
this is my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ginetto.martinelli.warehousenotification">
<uses-feature android:name="android.hardware.type.watch" />
<uses-permission android:name="android.permission.WAKE_LOCK" android:requiredFeature="true" />
<uses-permission android:name="android.permission.VIBRATE" android:requiredFeature="true"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#android:style/Theme.DeviceDefault">
<uses-library
android:name="com.google.android.wearable"
android:required="true" />
<meta-data
android:name="com.google.android.wearable.standalone"
android:value="true" />
<activity
android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name=".MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="#string/default_notification_channel_id"/>
</application>
</manifest>

Why Custom Launcher doesn't work properly sometimes?

I created a custom launcher and set it to default launcher for my tablet. but when I open an application and then press Back button I will go to the last launcher(Default launcher of Samsung) although I setup my launcher as default before!
This is my launcher manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="launcher.base.app.ehsan.com.minelauncher">
<!-- To access internet -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- To auto-complete the email text field in the login form with the JSON's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.READ_PROFILE"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<application
android:name=".tools.G"
android:allowBackup="true"
android:icon="#mipmap/logo"
android:label="#string/app_name"
android:supportsRtl="false"
android:theme="#style/AppTheme">
<activity android:name=".activity.MainActivity">
</activity>
<activity
android:name=".activity.LoginActivity"
android:label="#string/title_activity_login"
android:theme="#android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"
android:launchMode="singleTask"
android:stateNotNeeded="true"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".activity.ForgetActivity"
android:screenOrientation="sensorLandscape"
>
</activity>
<activity
android:name=".activity.RecoveryActivity"
android:screenOrientation="sensorLandscape"
>
</activity>
<service
android:name=".APIService.InternetService"
android:enabled="true"
android:exported="true"/>
</application>
</manifest>
Thank you for Your answers.

change default start activity error

This is my code
<?xml version="1.0" encoding="utf-8"?>
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".RegisterActivity"/>
<activity
android:name=".SplashActivity"
android:exported="true" />
<activity
android:name=".LoginActivity"/>
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" />
</application>
At the beginning, my project exported property is in the LoginActivity section.
But after I change exported="true" to SplashActivity it's not work...
I tried to change to RegisterActivity section and got the same error.
Event log is "Error running app: The activity must be exported or contain an intent-filter"
my android studio version is 2.3.3 and project min SDK is 19
Is there anyone have the same problem?..
Updare:
This is my latest code
<?xml version="1.0" encoding="utf-8"?>
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".RegisterActivity"/>
<activity
android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".LoginActivity" />
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" />
</application>
But I got the
same problem
...
try defining your Splash activity like this :
<activity
android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
In the Manifest file you must have an Activity that is set as Main so the app will know what to launch first.
By adding the following intent-filters you set the following Activity as main.
<activity
android:name=".Activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

AppIcon will showed twice on device with Android App

When i install my android application on the device, the AppIcon will appear twice.
This means: there are two separate app-icons. Both icons launch the same app version. If I remove one app-icon, the other disappears also. If i reinstall them, it appears twice again.
How can i avoid this?
This is my AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.******"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="22" />
<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:theme="#style/AppTheme">
<meta-data android:name="com.bugsnag.android.API_KEY"
android:value="524b0194108e90ae383189e509746766"/>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<activity
android:name=".SplashActivity"
android:theme="#style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
It's because of the intent-filter. Only one activity should have
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Any activity having this intent filter will be shown in the launcher.

Live wallpaper with MainActivity

I have livewallpaper, settings activity for livewallpaper and also standard MainActivity.
The point is that livewallpaper can't works with MainActivity together.
When my manifest looks like this:
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.BIND_WALLPAPER"/>
<uses-feature android:name="android.software.live_wallpaper" />
<application android:icon="#drawable/icon"
android:label="simea">
<!-- >android:permission="android.permission.BIND_WALLPAPER">-->
<service android:name=".LiveWallpaper"
android:label="#string/app_name"
android:icon="#drawable/icon">
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data android:name="android.service.wallpaper"
android:resource="#xml/livewallpaper" />
</service>
<activity android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="#string/livewallpaper_settings"
android:name=".LiveWallpaperSettings"
android:theme="#android:style/Theme.Light.WallpaperSettings"
android:exported="true"
android:icon="#drawable/icon">
</activity>
</application>
I can run MainActivity, but I can't bind livewallpaper with my homescreen. I see preview of livewallpaper and I can change settings, but when I click "set wallpaper" button, there's no effect.
When I uncomment this line:
<!-- >android:permission="android.permission.BIND_WALLPAPER">-->
and comment this:
<uses-permission android:name="android.permission.BIND_WALLPAPER"/>
livewallpaper works great on my homescreen, but when I try to run MainActivity I get toast with message like this: "app is not installed on your phone".
How can I fix it?
the android:permission="android.permission.BIND_WALLPAPER" should be placed inside the service tag:
<service android:name=".LiveWallpaper"
android:label="#string/app_name"
android:icon="#drawable/icon"
android:permission="android.permission.BIND_WALLPAPER">

Categories

Resources