<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="muazam.multiplication.one"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="3" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:label="#string/app_name" android:name=".multiplication">
<intent-filter android:priority="1">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="#string/app_name" android:name=".splash">
<intent-filter android:priority="3">
<action android:name="android.intent.action.CLEARSCREEN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:label="#string/app_name" android:name=".Menu">
<intent-filter android:priority="2">
<action android:name="muazam.multiplication.one.Play" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
I want it to start with the .splash class first, and then .Menu class.
As you see I have put android:priority on them, but it seem to do nothing.
Anyone know how to solve this problem? Thanks.
I want it to start with the .splash class first
That has no meaning in Android.
If you meant to say "I want the .splash class to be what launches when the icon in the home screen launcher is clicked", then you need to get rid of the .splash class' current <intent-filter> (which is simply wrong) and move your MAIN/LAUNCHER <intent-filter> from the .multiplication class to the .splash class.
While you are at it, please get rid of the android:priority attributes (which are not used here) and your Play/DEFAULT <intent-filter> (which you really should not need, unless you plan on third-party apps starting up that activity directly).
and then .Menu class
You do this in Java code with startActivity().
As you see I have put android:priority on them, but it seem to do nothing.
Of course. There is no android:priority attribute for the <activity> element, as you can see in the documentation.
Activities aren't run automatically like a 'slide show' (although you could write your own code that way if you really wanted to).
The android:priority attribute is used for an entirely different purpose (from the docs for <intent-filter>...
It provides information about how able
an activity is to respond to an intent
that matches the filter, relative to
other activities that could also
respond to the intent. When an intent
could be handled by multiple
activities with different priorities,
Android will consider only those with
higher priority values as potential
targets for the intent.
In other word, if you have two activities each having an intent filter with the same action and category, then any Intent sent (from a 3rd party app) with those action/category details, will be passed first to the Activity whose intent filter has the highest priority.
This has nothing to do with how an app (and its activities) behave internally at runtime.
Related
In my app I have 3 activities, MainActivity, SecondaryActivity and TertiaryActivity. I want SecondaryActivity to be a default app link handler for a particular domain on Android 6, as described in this guide. At the same time, I want another activity, TertiaryActivity, to be able to handle links from another domain, but not be a default handler, as I don't own the domain. Here's my AndroidManifest to illustrate:
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.antonc.applinktest"
xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".SecondaryActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter android:autoVerify="true"> <!-- TRUE -->
<data android:scheme="https"
android:host="secondary.com"/>
<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=".TertiaryActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter android:autoVerify="false"> <!-- FALSE -->
<data android:scheme="https"
android:host="tertiary.com"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
</application>
</manifest>
I read through this extensive guide on app links that explains the mechanics of app link handling and app verification on Android, and here's the messages I see in logcat related to app verification:
03-25 17:54:45.640 1481-1481/com.google.android.gms D/IntentFilterVerificationReceiver: Received ACTION_INTENT_FILTER_NEEDS_VERIFICATION.
03-25 17:54:45.644 1481-30947/com.google.android.gms I/IntentFilterIntentService: Verifying IntentFilter. verificationId:12 scheme:"https" hosts:"tertiary.com secondary.com" package:"com.antonc.applinktest".
03-25 17:54:46.762 1481-30947/com.google.android.gms I/IntentFilterIntentService: Verification 12 complete. Success:false. Failed hosts:tertiary.com,secondary.com.
As you can see it attempts to verify both secondary.com and tertiary.com, even though I explicitly set android:autoVerify="false" for the intent filter on tertiary.com!
Is this an Android bug? How do I make sure that IntentFilterIntentService only verifies the intent filter for which I have set android:autoVerify="true" and leaves the other one out?
Is this an Android bug?
Since the behavior appears to be documented, I would describe it as a limitation. Quoting the documentation:
When the android:autoVerify attribute is present, installing your app causes the system to attempt to verify all hosts associated with the web URIs in all of your app's intent filters.
(emphasis added)
My interpretation of that is that if auto-verify behavior is all-or-nothing at the app level. It is unclear to me why they wrote it that way. If that is the long-term plan, I would have expected the autoVerify attribute to be on <application>.
How do I make sure that IntentFilterIntentService only verifies the intent filter for which I have set android:autoVerify="true" and leaves the other one out?
Put them in separate apps, I guess.
I think you should leave out that android:autoVerify="false" instead of setting it.
Reading the documentation it says only if the attribute it present. It wont check the value.
When the android:autoVerify attribute is present, installing your app
causes the system to attempt to verify all hosts associated with the
web URIs in all of your app's intent filters.
If you do not add
android.intent.category.BROWSABLE
This will prevent Android from auto verifying that particular intent-filter.
I'm working on an Android app written by someone no longer with the company, and not understanding what the purpose is of creating a receiver for AppWidget updates. The manifest has the main activity which runs when the app is launched. As far as I can tell, the appwidget is never used and its code is separate from the rest of the app. I can't tell if this is a left-over and can be removed or if it is still in use. All of the tutorials and examples I find explain how to implement this, but not really why one would, especially in this case.
Code from the manifest file:
<application
android:debuggable="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/ConnectTheme" >
<activity
android:name="com.globalcrossing.connect.ConferenceListView"
android:label="#string/listTitle" >
<intent-filter android:label="#string/app_name" >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.globalcrossing.connect.Preferences"
android:label="#string/set_preferences" >
</activity>
<!-- Broadcast Receiver that will process AppWidget updates -->
<receiver
android:name="com.globalcrossing.connect.ConferenceWidget"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/widget_provider" />
</receiver>
... more activities I understand, deleted for brevity
</application>
as in Doc:
ACTION_APPWIDGET_UPDATE :
Sent when it is time to update your AppWidget.
means ACTION_APPWIDGET_UPDATE Action faire when:
1. an new instance of Your AppWidget added to Home Screen from AppWidget Chooser( from AppWidget provider),
2. when requested update interval having lapsed which you have provided in AppWidget meta-data file using android:updatePeriodMillis attribute , and
3. when device reboot
If the application has a corresponding home screen widget, which can be found under the widgets section in the all programs list, then you will need APPWIDGET_UPDATE. Otherwise it will be unnecessary noise to your application with no purpose.
I just created my first Android app, all works fine, but all of the activities are shown on my Android menu. What did I do wrong?
Screenshot: imgur.com/9CmXU
I want to have one icon, directing to MainActivity, not all activities
<!-- language-all: lang-html -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myApps.birthdaymeter"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/my_logo"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".BirthdayMeter"
android:label="#string/title_activity_birthday_meter" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".AboutWindow"
android:label="#string/title_activity_about_window" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ShowResult"
android:label="#string/title_activity_show_result" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This is my manifest, changing logo didn't help
The <intent-filter> tag is used to describe the type of Intents that each Activity will respond to. The "android.intent.action.MAIN" action says that this Activity is an entrance point for your Application (think the main method that a java program requires). The "android.intent.category.LAUNCHER" category tells the OS to display the Activity in your list of Applications. Adding the DEFAULT category is ok, but effectively the same as omitting the <intent-filter> tag completely (which I find to make for much cleaner and easier to read code). You should only be using the <intent-filter> tag with these two actions and categories on the Activity that starts when a user opens your app. If wanted an Activity within your application to be able to respond to some special intents, you would use the tag to define which it responds to.
Here's a link to the google dev pages to help you learn more about Intent Filters.
http://developer.android.com/guide/components/intents-filters.html
Here's the documentation for the <intent-filter> tag. It's not the easiest to understand though.
http://developer.android.com/guide/topics/manifest/intent-filter-element.html
And here's the docs for the Manifest file and the Intent class. Both of these are good for reference if you're not sure about which tags to use in your Manifest. Good luck!
http://developer.android.com/guide/topics/manifest/manifest-intro.html
http://developer.android.com/reference/android/content/Intent.html
You phrased your question extremely generally, so I am not sure what to answer. It seems like you haven't called nameOfActivity.this.finish() when you launched another activity
If you post your manifest file I can help a little more, but it looks to me like you have not declared your activities correctly.
It should be setup somewhat like this:
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name="Activity1"></activity>
<activity android:name="Activity2"></activity>
<activity android:name="Activity3"></activity>
</application>
Essentially, create an application declaration, and then include each activity within it.
I have searched and searched and cannot seem to find the answer to this specific question about a custom intent.
I have an application with 4 activities, 1 is the main that sets things up and the other 3 represent the different screens I present to the user. I am trying to use custom intents to start the different activities.
Here is my AndroidManifext.xml:
<?xml version="1.0" encoding="utf-8"?>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".Activities.REDB_main" android:label="#string/app_name"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Activities.ChooseCards" android:launchMode="singleTop">
<intent-filter>
<action android:name="#string/ACTION_VIEW" />
<action android:name="#string/ACTION_REFRESH" />
<category android:name="#string/CATEGORY_SHUFFLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".Activities.SelectSets" android:launchMode="singleTop">
<intent-filter>
<action android:name="#string/ACTION_VIEW" />
<action android:name="#string/ACTION_REFRESH" />
<category android:name="#string/CATEGORY_SELECT_SETS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".Activities.SelectCards" android:launchMode="singleTop"
android:permission="android.permission.ACCESS_CHECKIN_PROPERTIES">
<intent-filter>
<action android:name="#string/ACTION_VIEW" />
<action android:name="#string/ACTION_REFRESH" />
<category android:name="#string/CATEGORY_SELECT_CARDS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
I create a category for each application and then the two kinds of actions I want it to handle. I know that I could use explicit intents, but since I want to have different actions I figured that making the implicit intents would work better.
I call the first of my real activities from within my main with this:
Intent intent = new Intent().setAction(getString(R.string.ACTION_VIEW));
intent.addCategory(getString(R.string.CATEGORY_SHUFFLE));
startActivity(intent);
Of course, the reason I am here is because the above can never find the activity that matches the intent. The error messages states the action and category correctly and unless I'm wrong, the above manifest creates the intent-filters correctly.
Searching around online, I always seem to find examples with data also being used. I messed around with adding data just to see if it was necessary but it did not seem to matter.
On a slightly different note, is there a different way I should be controlling the flow of my program besides intents? The reason I have two actions is because 1 switches the view while the other is there to just refresh the data so that when the user switches to the screen later, they don't see it quickly refresh the data but instead just the new stuff.
I know that I could use explicit intents, but since I want to have different actions I figured that making the implicit intents would work better.
I rather doubt that. Mostly you use <intent-filter> when you want things other than your own app to start the component (e.g., third party apps).
Also, I doubt you want android:launchMode="singleTop" on all of those. And I am very certain that you do not want android:permission="android.permission.ACCESS_CHECKIN_PROPERTIES" on the last one, as you won't be able to launch your own activity then, most likely.
The error messages states the action and category correctly and unless I'm wrong, the above manifest creates the intent-filters correctly.
I have never seen an Android application use a string resource for a <category> element. Perhaps that is contributing to your difficulty. Also, since the <category> elements are not doing you any good that I can see (except your LAUNCHER one), I am unclear why you put them there.
I suggest that you just drop the <intent-filter> elements and use explicit Intents.
Don't use resource strings to make intents actions, use android.intent.action.VIEW instead
I defined an application which is only used from my other application. So I would like to hide the icon of this application, so that the user can't see it on the desktop of his phone (or how do you call the thing where all apps are listed?). My manifest file looks the following way:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xyz.games.pacman.controller"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.BLUETOOTH"/>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".PacmanGame"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="pacman.intent.action.Launch" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver android:name="xyz.games.pacman.network.MessageListener">
<intent-filter>
<action android:name="xyz.games.pacman.controller.BROADCAST" />
</intent-filter>
</receiver>
</application>
<uses-sdk android:minSdkVersion="7" />
</manifest>
I already read this question:
How to hide an application icon in Android emulator?
but if i just remove the line
<category android:name="android.intent.category.DEFAULT" />
in my manifest, the activity isn't working at all (ActivityNotFoundException in the calling activity).
Any hints how to solve this problem? I already tried android.intent.category.EMBEDDED but this doesn't work too.
In the Internet I found CommonsWare answer http://osdir.com/ml/Android-Developers/2010-06/msg03617.html that it can be done using PackageManager. Unfortunately, it isn't explained how exactly and I couldn't find a solution by browsing the PackageManager API.
You need to create a custom intent filter and then create an intent which uses that filter.
For example, in my Funky Expenses application external apps can add transactions. This is achieved by the manifest for Funky Expenses containing
<activity android:name="com.funkyandroid.banking.android.ExternalEntryActivity">
<intent-filter>
<action android:name="com.funkyandroid.action.NEW_TRANSACTION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
and then external application can access my activity in the following way;
Intent launchIntent = new Intent();
launchIntent.setAction("com.funkyandroid.action.NEW_TRANSACTION");
... code to set parameters to be passed to activity ...
startActivity(launchIntent);
Pay special attention to the setAction call which sets the correct intent.
why would you write an actual (executable) second application that merely exists to do something when it receives sth from another app?
i'd suggest, you implement this "app" as a service (remote or local). this service would then run in the background and do stuff for you and there won't be any icons to be displayed on the screen for it...
if neccessary, you can implement this service to be remote, meaning it runs in a totally different process then the first app. and: you actually can communicate via broadcast intents as you seem to do by now so you won't need to change your first app...
Try removing the intent-filter and instead of trying to launch the 2nd activity with the filter lounch directly the activity:
Intent second = new Intent(context, xyz.games.pacman.controller.PacmanGame.class);
startActivity(second);
You must remove the whole <intent-filter>, not just the <category>