Is there a way to detect from app code when it is being reinstalled.
I saw that app update from market can be detected by listening to PACKAGE_REPLACED event in broadcast receiver. But that these events are not delivered to the app , if the app is reinstalled from editor (eclipse ).
My requirement is that i am disabling a component(Launcher activity). The app install will fail if it is not enabled. SO everytime before reinstall i want to enable this component.
I am talking about the reinstall before publishing in market. While developing , each time i reinstall the app to test some modification, i want to detect this from my app and make the component enabled.
I saw from my example that the following events will be broadcasted when an app is reinstalled from eclipse.
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="android.intent.action.PACKAGE_REPLACED"/>
</intent-filter>
I defined a broadcast receiver for these actions and from onreceive i am able to enable my component
Related
I am developing an Android Wear biking app. I am trying to enable the "Ok Google, Start cycling" into my app. It works perfectly if I say it to the phone, but not to my Moto360. Also in the Android Wear app, I am unable to choose my app as the default for "Start bike ride" Any suggestions?
This is what I have in my manifest, and it is based off of Google's example.
<intent-filter>
<action android:name="vnd.google.fitness.TRACK" />
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="vnd.google.fitness.activity/biking"/>
</intent-filter>
I searched other similar questions but didn't find a result.
Thanks for your help
Providing a Wear app is a requirement for being listed in the available apps to register for a system provided voice intent on Android Wear and appear in the Android Wear application for choosing as the default for that voice action. Per the Adding Voice Capabilities training, you attach the appropriate <intent-filter> to an activity in your Wear app. One point of note if you aren't ready to provide a full Wear app is this section of the same page:
When users speak the voice action, your app can filter for the intent that is fired to start an activity. If you want to start a service to do something in the background, show an activity as a visual cue and start the service in the activity. Make sure to call finish() when you want to get rid of the visual cue.
In your case, your activity could just display a visual cue that you are launching something (say using a ConfirmationActivity with an OPEN_ON_PHONE_ANIMATION from the Wearable UI library) and then send a message to your phone app, which would then listen for that message using a WearableListenerService and start the bike ride on the phone, posting your notification.
Note that a full Wear app with more customization is going to be expected as many apps, such as Runtastic on Android Wear add quite a few more abilities that augment the standard experience. While not out yet, an upcoming release of Android Wear will be adding offline (i.e., without a phone) GPS support for Android Wear watches that have GPS ability (currently only the not yet released Sony Smartwatch 3) and of course those abilities will require a full Android Wear experience and cannot rely on a phone app (although details have not yet been released).
You need to add a launcher intent-filter to it; then, saying "OK Google, start [app name]" will start the app. The launcher filter is:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
I am trying to receive SMS from my android app. I have following receiver specified in my manifest.
<receiver android:exported="true" android:name="com.lahiruchandima.myapp.SMSReceiver">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
SMSReceiver successfully receives SMS if my app is installed and opened once (app does not need to be running at the moment the SMS is received to the device). But, if i do not open my app at least once after a fresh install, it doesn't receive any SMS.
Does anybody know a way to make it possible to receive SMS without opening the app at least once?
Does anybody know a way to make it possible to receive SMS without opening the app at least once?
It can't be done, on newer Android versions at least. Ever since Android 3.1, apps are installed in a stopped state, and require that the user open it at least once before components like your BroadcastReceiver can function. This is for security reasons, to prevent, or at least hamper, malicious program behavior.
I'm developing an android application that I want that starts when the device is opened and remains on foreground until it is closed. To achieve this I have used some tricks that I found surfing the Internet:
Start application when device starts >> Solved using a broadcast receiver that handles the android.intent.action.BOOT_COMPLETED
Ignore the Home button when the application is opened >> Solved using an Activity Alias that is installed when the app starts and uninstalled when the application closes
I test the solution and it works fine almost always. When I close the device with the app executing and it restarts the device the application is opened twice. I think that the extra opening is due because the Activity Alias wasn't uninstalled because the app doesn't close properly when I shutdown the device.
Is there a solution to avoid this behavior?
Thanks
You should use ACTION_SHUTDOWN and perform necessary task on shutdown.Find more details here.
You can maybe use the Shutdown intent to finish your activity when the device is shutting down.
<receiver android:name=".myReceiver">
<intent-filter>
<action android:name="android.intent.action.ACTION_SHUTDOWN" />
</intent-filter>
</receiver>
Then you can just use the activity.finish(); to close your app.
I have an app that is started on bootup via manifest entries:
<receiver android:enabled="true" android:name="com.vwp.owmini.BootUpReceiver"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<action android:name="android.intent.action.BOOT_COMPLETED" />
This app itself starts - dependent on configuration - a foreground service and brings own Activity to background. This works well and without problems.
But: when the app is updated because a new version is available in Playstore, it is stopped but not restarted afterwards.
So: how can I tell Android to restart this app after an (automated) update from Playstore?
Thanks
From another SO-question
Register a BroadcastReceiver to Intent.ACTION_PACKAGE_REPLACED
Then, compare EXTRA_UID with your own. If it matches, you can start
your service again.
I have an Android app that listens to SMS messages. This is in the manifest:
<receiver android:name=".IncomingSMSBroadcastReceiver" android:enabled="true">
<intent-filter android:priority="100">
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
</intent-filter>
</receiver>
The broadcast receivers works fine if the app is installed and opened. But I want the receiver to be able to be called immediately after install, in case user has remotely installed from the Android Market website and is not present in front of the phone. When I install APK using adb
./adb install myapp.apk
I can see the app is installed. But when I send a SMS message, my app doesnt respond. After I open the app once, it appears all the initialization happens at this point, and now the app responds to SMS messages just fine.
One possibility is that the ADB install is different from the Market install.
Any ideas?
It is not Possible. AFAIK until receiver is not registered then it can not detect any action.You have not any problem with code.But your receiver will work when it start one.For this we have to run our application at least one time.So that Manifest Register the Receiver