I'm opening an application with custom URLScheme. The problem is, that when there is already an instance of app/activities in this app, when clicking HOME and running application from URL, the new instance of app is created.
The question is: how do I finish all the activities already created and running before launching the app again?
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nomtek.activities">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".FunctionsActivity"
android:configChanges="orientation|screenSize"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="ax4s" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
<activity
android:name=".AboutActivity"
android:configChanges="orientation|screenSize"
android:label="#string/title_activity_about" >
</activity>
<activity
android:name=".FunctionActivity"
android:configChanges="orientation|screenSize"
android:label="#string/title_activity_function">
</activity>
<activity
android:name=".BarcodeCaptureActivity"
android:label="#string/title_activity_barcode_capute"
android:screenOrientation="fullSensor"
android:stateNotNeeded="true"
android:theme="#style/zxing_CaptureTheme"
android:windowSoftInputMode="stateAlwaysHidden">
</activity>
</application>
You can Use SharedPreferences for that. Have a look at this.
Related
I'm working on a app in Xamarin Android and got stuck on this error, after changing target sdk/Android version from Android 9 to Android 10:
my AndroidManifest (in Visual Studio!):
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.7.1" package="com.INCREDIBLE.Video2mp3" android:installLocation="auto" android:versionCode="3">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29" />
<application android:allowBackup="true" android:label="#string/app_name" android:roundIcon="#drawable/micon" android:supportsRtl="true" android:theme="#style/AppTheme" android:icon="#drawable/micon">
<activity android:name=".MainActivity" android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:label="Download als mp3">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest>
But in the Solution folder the Manifest looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.7.1" package="com.INCREDIBLE.Video2mp3" android:installLocation="auto" android:versionCode="3">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application android:allowBackup="true" android:label="#string/app_name" android:roundIcon="#drawable/micon" android:supportsRtl="true" android:theme="#style/AppTheme" android:icon="#drawable/micon" android:name="android.app.Application">
<activity android:name=".MainActivity" android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:label="Download als mp3">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
<activity android:icon="#drawable/micon" android:label="#string/app_name" android:launchMode="singleTask" android:name="com.INCREDIBLE.Video2mp3.MainActivity" android:theme="#style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="1999999999" android:authorities="com.INCREDIBLE.Video2mp3.mono.MonoRuntimeProvider.__mono_init__" />
</application>
</manifest>
The App should only have one Activity (MainActivity). If deleting the 'duplicated' <activity ... /> (in the file directly) I get no error massage, but the build fails anyways. Before the version changed from 9 to 10, it worked as expacted. Now (even when I change the target Version back to 9) I get stuck here.
In Xamarin, you don't need to explicitly register Activities in the Manifest. You can delete all activity code from the manifest and use Attributes in the source file like so:
[Activity(MainLauncher = true, LaunchMode = LaunchMode.SingleTask)]
[IntentFilter(new[] { "android.intent.action.SEND" }, Label = "Download als mp3", Categories = new[] { "android.intent.category.DEFAULT" }, DataMimeType = "text/plain")]
public class MainActivity: Activity
{
Note: You may be doing both due to which a second entry for the activity maybe gets added to the manifest when you build the project
I installed my signed apk on android emulator and when I tried to uninstall it, android made a dialog and said
MyApp is part of the following app: MyApp
do you want to uninstall this app?
I wanna know what makes android to make this dialog because my app(MyApp) is not part of another app
and this is my Manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app.driver.android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.sec.android.provider.badge.permission.WRITE" />
<application
android:name=".global.Application"
android:allowBackup="false"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="false"
android:theme="#style/AppTheme">
<activity android:name=".activity.SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activity.HomeActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="home_activity"
android:scheme="app_driver" />
</intent-filter>
</activity>
<activity
android:name=".activity.ActivationActivity"
android:screenOrientation="portrait"
android:theme="#style/AppTheme"
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".activity.LoginActivity"
android:screenOrientation="portrait"
android:theme="#style/AppTheme" />
<activity
android:name=".activity.NoInternetConnectionActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.ProfileActivity"
android:screenOrientation="portrait"
android:theme="#style/AppTheme2"
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".activity.MapActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".activity.RequestActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
</application>
</manifest>
Same problem. But I resolved it after I located that there was 2 activities that has different labels.
When I develop my application onto my mobile phone, a lot of same icons of my application appears. So I have got icons for each Activity (sometimes twice). Not every symbol will work (the most of them shut down directly after clicking)
What's wrong?
Here is my AndroidManifest.xml:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<permission
android:name="com.unitnode.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:largeHeap="true"
android:backupAgent="com.unitnode.FileBackup"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.unitnode.OpenProject"
android:label="#string/app_name"
android:parentActivityName="com.unitnode.Collection" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.unitnode.Property"
android:label="#string/Settings" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.unitnode.SoundRecord"
android:label="#string/Settings" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.unitnode.FullscreenMode"
android:label="#string/fullscreenMode" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.unitnode.DatenbankHelper"
android:label="#string/Settings" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.backup.api_key"
android:value="AEdPqrEAAAAIgcHi_mYg2z3r6ovsAyWLlVO7Zk7oKPCBxIJb-Q" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyBT21LxMEdlR6cecCXb913IPo7cIP-oMiU" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
Each activity that has this intent filter gets a launcher icon:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Remove the intent filter from the activities that should not have one.
<category android:name="android.intent.category.MAIN" />
this line appears on your 2 activities and this cause the problem you have.
you need to write this line on the main activity that need to load when the user open the application
Im working on android map API and I got it working. The problem is when add a new activity (.ListActivity) and make it my Launcher the console is giving me an error "No Launcher found". Here is my code...
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.themap"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="17" />
<permission
android:name="com.example.themap.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.themap.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my_key" />
<activity
android:name="com.example.themap.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.themap.ListActivity"
android:label="#string/title_activity_list" >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</activity>
</application>
It has to be in an intent-filter together with the MAIN.
<activity
android:name="com.example.themap.ListActivity"
android:label="#string/title_activity_list" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
In your second activity addition you forgot to add intent-filter tags. that is why you are getting the error.
Change your xml file second activity addition as below.
<activity
android:name="com.example.themap.ListActivity"
android:label="#string/title_activity_list" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
tag is missing in com.example.themap.ListActivity
Also you have more than one android.intent.action.MAIN defined
This is defined in both your activities
Refer - http://developer.android.com/reference/android/content/Intent.html#ACTION_MAIN
I am trying to fix the issue for hours but I couldn't. The app is not launching activity I mentioned in the manifest, see following
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="green.thumbup"
android:versionCode="1"
android:versionName="1.1" >
<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="17" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<permission
android:name="green.thumbup.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<supports-screens android:anyDensity="true" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<application
android:icon="#drawable/app_icon"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="" />
<activity android:name=".driver.DriverMap" >
</activity>
<activity android:name=".driver.Journey" >
</activity>
<activity android:name=".journey.PassengerDestination" >
</activity>
<activity android:name=".login.Login" >
</activity>
<activity android:name=".passenger.PassengerDestination" >
</activity>
<activity android:name=".passenger.PassengerInfo" >
</activity>
<activity android:name=".users.RegisterUser" >
</activity>
<activity android:name=".users.UserChoice" >
</activity>
<activity android:name=".driver.ThumbUpGoogleMap" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
ThumbUpGoogleMap is in green.thumbup.driver.ThumbUpGoogleMap package.The application is always launching Loging activity from green.thumbup.login.Login, which is old main activity. Login was launch in the previous build but I completely removed and rebuilding the application.
I tried following but not success
I cleaned the code multiple times
I created a new AVD
I change activity path to android:name="green.thumbup.driver.ThumbUpGoogleMap"
Also tried
This is driving me crazy, any hint, suggestion would be of great help
Please write these two lines with activity declaration. And try to give full name for activity instead of just
.driver.ThumbUpGoogleMap
<activity android:name="green.thumbup.driver.ThumbUpGoogleMap" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
And remove <action android:name="android.intent.action.MAIN" /> from your Main Activity declaration.
Try this
<activity android:name=".driver.ThumbUpGoogleMap" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
EDIT:
If this doesnt solves the issue.. make this 4 lines
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
are used only once in the manifest file between any activity tags