i want receive all start app intents (i think MAIN/LAUNCHER, see below) to log how often i used the application. So i do not want create an activity... I tried several receiver blocks, but for now nothing works:
with, without priority, only the action, both, only the category and so on..
<receiver android:name=".Receiver" android:enabled="true"
android:process=".e">
<intent-filter priority="100000" android:priority="100000">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</receiver>
Have anyone an idea?
Thanks
I want receive all start app intents
You cannot do that, sorry.
Related
Hi I know this question has been asked multiple times but my requirement is a little different so pls bear with me.
I use two different libraries in my android application. One is for parse push notification which has the following declarations:
<receiver
android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="com.airloyal.ladooo" />
</intent-filter>
</receiver>
and the declaration for the other receiver is:
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="com.airloyal.ladooo" />
</intent-filter>
</receiver>
I definitely need both the libraries in my app so removing one is not an option. I use both the receivers for different purposes. But when I declare both the receivers there is a conflict and I am not able to receive any push notifications.
Can someone pls point me in the right direction?
P.S Both the libraries are jar files and I do not have control over the receivers of both. So forwarding is not an option.
Any help would be appreciated. Thanks
If the broadcast receivers are conflict with each other, you may try to set the priority of your receiver in the AndroidManifest.xml in <intent-filter>
Use this attribute only if you really need to impose a specific order in which the broadcasts are received, or want to force Android to prefer one activity over others.
The value must be an integer, such as "100". Higher numbers have a higher priority. The default value is 0. The value must be greater than -1000 and less than 1000.
sample code:
<intent-filter android:icon="drawable resource"
android:label="string resource"
android:priority="integer" >
. . .
</intent-filter>
Also, another way to solve, please refer to here.
I wanted to register my launcher activity so it could be started by both clicking on icon and opening link with a custom scheme. I managed to make it work but am questioning is this correct way. This is the relevant part of my manifest:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<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:scheme="my.sheme" />
</intent-filter>
This does work but I was wondering should I register both actions under same intent filter. I tried just moving tags from second filter to the first one but then my activity doesn't show icon on install. Is it possible to do it this way and I just made some small syntax error(or broke some undocumented order of declaration rule) or is my thinking completely wrong on this and there are deeper reasons why this doesn't work?
NOTE:I do set android:exported="true"but android.intent.action.MAIN works even without it because it becomes exported anyway if you use action.MAIN
As the Android documentation states:
When you want to handle multiple kinds of intents, but only in specific combinations of action, data, and category type, then you need to create multiple intent filters.
Otherwise you can group them into one intent-filter.
I have a gcm receiver, but it is not working before restarting phone and after clean memory. What should i change to guarantee receiver is always working?
<activity
android:name="com.example.diyet.MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.plugin.gcm.PushHandlerActivity"/>
<receiver android:name="com.plugin.gcm.CordovaGCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.plugin.gcm" />
</intent-filter>
</receiver>
<service android:name="com.plugin.gcm.GCMIntentService" />,
thanks in advance
if u want to start your receiver manually then use
registerReceiver(receiver) inside your activity
Sorry I don't know anything about GCM but if I get you right you have one of the following possibilities
If your GCMIntentService is custom, you can make this Service STICKY So the OS restarts it after a Crash. To do this you have to return return Service.START_STICKY; in your onStartCommand Method.
Also you can Register for the android.intent.action.BOOT_COMPLETED to get your Service started right after device is Booted.
If you want to prevent the Service to Crash, when the App Crashes you have to put it in another Thread. This can be achieved by Setting an custom Process Name in the Manifest
android:process="com.gigatronik.presenter.serialport.SerialPortListenerService"/
I will edit this answer, if you can give me more information on your Problem, since I never used GCM
in my app, there is two activity and i want to make activity1 to the starting activity after installation.
But now the RUN button (is showed right after packgae installing) is disabled.
below is the manifest file. thanks.
<activity ...1>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity ...2>
<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.ACTION_POWER_CONNECTED" />
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
</intent-filter>
</activity>
android) can i set a default activity that runs right after installing
No activity "runs right after installing". The user has to launch it from the launcher.
below is the manifest file
No, it is not. That is not even valid XML.
Also, note that your third <intent-filter> is invalid. Not only are you missing any category (you need at least DEFAULT for activities), but ACTION_POWER_CONNECTED and ACTION_POWER_DISCONNECTED are not activity actions.
I am going to take a guess that you really mean to ask: "I have two activities, both described as ACTION_MAIN/CATEGORY_LAUNCHER, and now the Run button does not work -- what can I do?" The answer would be "either remove the ACTION_MAIN/CATEGORY_LAUNCHER <intent-filter> from one of them, or mark one of the two as disabled (android:enabled="false") and enable it later on using PackageManager."
I think the problem is the second:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
You shouldn't have 2 activities flagged as the MAIN and LAUNCHER activity.
Try removing it within activity2.
Check out: http://developer.android.com/reference/android/content/Intent.html the intentfilter s are discussed.
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