I would like my main activity to be searchable also but when I change the manifest.xml to
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<!-- declare the default searchable Activity for the whole app -->
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
it cant find the main activity and the application doesn't run.
any idea?
is it not best practice to use the same activity as searchable also?
Thanks,
Alisa
You need to add a new intent-filter with the action.SEARCH
<activity
android:name=".activities.YourActivity">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
</activity>
You need add new action in manifest file and link to search metadata, smth like that:
<intent-filter>
<action android:name="android.intent.action.SEARCH"/>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="#xml/searchable"/>
Related
I have in my AndroidManifest.xml two activities that I could launch
<activity android:name=".ExperimentActivity"
android:label="Experiment">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"
android:label="Main">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
When I install, there's two icons, Main and Experiment. However, when I launch, both also launch the ExperimentActivity.
Did I miss anything?
Please add the exact package like
android:taskAffinity="com.yourpackage.MainActivity"
and
android:taskAffinity="com.yourpackage.ExperimentActivity"
to your activity tag .
Hope this helps.....
So, normally you only launch the Main Activity, which is declared as your launcher in the manifest. All other activities then get launched from the Main Activity.
You should only declare one Launcher Activity in your manifest.
E.g.:
<activity android:name=".ExperimentActivity"
android:label="Experiment">
<intent-filter>
<!-- declare your own filters if you need them -->
<!-- for example parent activities -->
</intent-filter>
</activity>
<activity android:name=".MainActivity"
android:label="Main">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I found another way of doing so, which is to add the following to my ExperimentActivity scope.
android:launchMode="singleInstance"
i.e.
<activity android:name=".ExperimentActivity"
android:launchMode="singleInstance"
android:label="Experiment">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"
android:label="Main">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Currently my ActivityMain.java is main in my app android. How can I change the activity that started with my android app ?
Thank you so much.
In you manifest, put
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
between Activity tag
<activity
android:name="com.some.activity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I'm working on an Android app using Eclipse and just started noticing a weird glitch.
When I deploy the app to my phone for some reason multiple app icons appear in my "Apps" folder area. Each icon brings me to a different class page within my app when tapped. Has anyone else experienced this as well?
Here's a screenshot of the issue when running the app from the emulator on my laptop.
Since the issue is appearing in the emulator I know that it isn't my phone that's causing the error.
Each of the icons you see in that screenshot represents a different activity in my manifest file.
Here's how the activity is set up in my manifest.
<activity android:name=".MainJava">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".AppClass">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Would you say that this error being caused because of the way that I am setting up the activities? If so, how would you suggest that I edit the activities to fix this problem?
I've never seen this in any of the apps I've built before this one.
Only MainActivity(Launcher Activity) have intent filter with action as Main and category as Launcher,
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
And Remove this Two line For other Activity.
Change from:
<activity android:name=".MainJava">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".AppClass">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
To:
<activity android:name=".MainJava">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".AppClass">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
There should be only one MAIN and one LAUNCHER
In my app I have the main activity defined in the manifest.xml file like this:
<activity
android:name=".MainActivity"
android:label="#string/guide_activity" >
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="#xml/searchable"/>
</activity>
when I run the project from eclipse connected to a real device or an emulator I receive the following message in the console:
No Launcher activity found
what can be the reason of this ?
Split the intent-filter into two seperate ones. If you mix them like this, android won't determine that one of the two is the launcher filter.
<activity
android:name=".MainActivity"
android:label="#string/guide_activity" >
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="#xml/searchable"/>
</activity>
now i am learning intent filters..I got some some example like view contacts,make call.But all in those examples they used default in android.manifestfile..
< intent-filter >
<action android:name="android.intent.action.MAIN" >
<category android:name="android.intent.category.LAUNCHER" >
< /intent-filter>
this is ok for single .java file application.If i am using implicit intent in my second activity, then how will be the of my second activity manifest file?..just take the examplw of view contact....
Intent contact=new Intent(Intent.ACTION_VIEW,ContactsContract.Contacts.CONTENT_URI);
my class name is ViewContacts.java and package name is com.phone.contact...
The intent filter is specified within the Activity tag and you can specify multiple filters per activity.
<activity android:name=".activities.WaypointMap" android:launchMode="singleTop" android:theme="#style/Theme.NoBackground">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.app.searchable" android:resource="#xml/searchable" />
</activity>
<activity android:name=".activities.WaypointList" android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.app.searchable" android:resource="#xml/searchable" />
</activity>