I have this code in my manifest which allows me to set different activities in my application as the launcher. Is there a way that I can implement a button so that on button click it allows me to change the default launcher? For example, when I set the default launcher as settings activity, home activity can't be set as the default. I want the option to change it.
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".SettingsActivity"
android:label="#string/title_activity_settings" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".HomeActivity"
android:label="#string/app_name"
android:launchMode="singleTask"
android:stateNotNeeded="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
You can use PackageManager to disable/enable each of your app components but perhaps it would be simpler to stick to one entry point in your app (like StartActivity with no UI (i.e. themed Theme.NoDisplay) which would then call startActivity() on the right one depending on user config.
Related
Ok here is the thing I created a project put it on github, then work more on it update it and push updates on github (this is the last version, 2 versions total)...however now whenever I run the app through android studio,(even the version downloaded from github, master) it installs two APPs on my phone...one is the older version and the other is the new version.. How can I remove the old version ? however I only see one android manifest, it seems that both versions are kinda connected together whenever I uninstall, the phone uninstalls them both
EDIT Before fixing
<?xml version="1.0" encoding="utf-8"?>
<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=".TeacherLogin">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".AddUpdateStudent" />
<activity android:name=".ViewAllStudents" />
<activity android:name=".MainActivity" />
<activity android:name=".NoteMainActivity" />
<activity android:name=".AddNotesActivity" />
<activity android:name=".MainMenuActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
After Fixing
<?xml version="1.0" encoding="utf-8"?>
<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=".TeacherLogin">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".AddUpdateStudent" />
<activity android:name=".ViewAllStudents" />
<activity android:name=".MainActivity" />
<activity android:name=".NoteMainActivity" />
<activity android:name=".AddNotesActivity" />
<activity android:name=".MainMenuActivity">
</activity>
</application>
Ok so appearntly the second intent was after the main menu which was the version 1.0 before the update, after the update I added login activity, hence why it looked like "2 apps with different versions" so there was no problem what so ever with git or github as I weirdly thought... I appologize if this question was kinda stupid now after I looked at it but I am really new to this android app development.
If you have two launcher icons, but only one entry in Settings > Apps, that means your one app has a manifest with two <activity> elements that each have the <intent-filter> to cause them to appear in the launcher:
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SomeOtherActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
That may just be a copy/paste error, or perhaps an accidental checkbox click in the new-activity wizard.
Regardless, unless you really do want two launcher icons, remove the <intent-filter> from the activity that does not belong in the launcher.
So I am very new to android programming and I was installing a basic app I just built on my android device and I find that it always seems to install two "instances" of the app ? Here is a screenshot of what I am looking at [The two instances are of the SR520 app] :
I did some research and it seems like it could be due to the android manifest file but I am not exactly sure what I should change in it. This is what my manifest file looks like
<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=".SplashActivity" android:theme="#style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Some suggestions would be much appreciated.
Ok I guess I needed to delete this section
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
That fixed the issue.
I am new to Android development...
I have an application which uses a library to upload data to a website. I want to make additions to the application to be able to read NFC tags.
I started out creating a small, separate application to get the hang of NFC. That app works fine. Now, I need to bring in some of that code into this other application which depends on the aforementioned library.
The problem is, UNLESS I add an application node to the AndroidManifest.xml in the LIBRARY specifying the NFC intents, the intents do not fire.
[Snippet from library manifest mentioned above]
<application
android:supportsRtl="true"
android:allowBackup="true">
<activity
android:name=".MainActivity"
android:label="My App..."
android:supportsRtl="true">
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
[The main application contains this application node in its manifest]
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.microsoft.azure.storage.samples.MainActivity"
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>
<action android:name="android.nfc.action.TECH_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<meta-data
android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="#xml/nfc_tech_filter" />
</activity>
</application>
Now comes the problem.... when a tag is detected, android tries to launch the activity from the library manifest file. Since that activity doesn't exist, I get a ClassNotFoundException. I tried specifying MainActivity class from the application for the android:name of the application node in the LIBRARY manifest, but:
I can't compile the code.
It would be extremely poor practice even if that worked...
How do I get the NFC intents to fire without having to add intent-filter nodes in the library manifest?
Thank you!
I have an existing Android Studio project and i wanted to remove splash screen. I tried to remove changes in AndroidManifest.xml but couldn't make it.
Here this my actual AndroidManifest.xml
<!-- Home Tab Group -->
<activity
android:name=".view.TabHomeActivity"
android:label="#string/app_name"
android:windowSoftInputMode="adjustPan|stateHidden" >
</activity>
<activity
android:name=".view.activity.SplashActivity"
android:label="#string/app_name"
android:windowSoftInputMode="adjustPan|stateHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".view.activity.TestLoginFacebookActivity"
android:configChanges="keyboardHidden|orientation"
>
</activity>
<!-- Tab Screen -->
<activity android:name=".view.tabscreen.TabHomeScreen"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize" />
Delete the SplashActivity class,delete it from the manifest. Set the Launching Activity first which you want to come as your first screen
<activity
android:name=".view.TabHomeActivity"
android:label="#string/app_name"
android:windowSoftInputMode="adjustPan|stateHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".view.activity.TestLoginFacebookActivity"
android:configChanges="keyboardHidden|orientation"
>
</activity>
Delete the SplashActivity class,
delete it's layout,
delete it from the manifest.
Add the intent filters to your TabHomeActivity.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
I can't find any problem but it keep giving me the error "No Launcher activity found!" and "The launch will only sync the application package on the device!"
can anyone solve this problem???
This is my Maniest
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.saikoro.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.saikoro.StartUp"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.saikoro.StartUp" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
The <activity> element of the activity you want to launch through the icon on the app list must contain both of the following parts of the intent-filter:
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
</intent-filter>
Your current manifest has an activity with category LAUNCHER and action MAIN, but in different activities. The one with the icon in the app list must have them both.
Change
<action android:name="com.example.saikoro.StartUp" />
with
<action android:name="android.intent.action.MAIN" />