How to start an Activity or an IntentService before an application will be uninstalled by the user who has earlier installed the app on there device?
One way to achieve what you want would include the following steps:
(temporarily) rooting the device
converting the app in question into a system app (e.g. using Titanium Backup ★ root, but there are also other apps helping you with this step)
unroot the device again
As the app now resides in read-only space (/system), the user cannot delete it without either rooting the device or flashing a ROM -- which of course could be done, but it's a higher inhibition threshold at least.
There is no such thing as impossible with computers. There is only difficult and highly improbable to happen anytime soon. This is a fact not an opinion. Often someone says "impossible" and there is someone interrupting them saying "Just did it.".
You cannot prefend an user removing an application.
The DELETE intent will be send when the user requests to uninstall.
The PackageManager will receive this intent and start uninstalling the application.
So, without any Android modifications, you cannot add an password.
You have to use Intent filter called "android.intent.action.DELETE" in the AndroidManifest.xml
Like below
<activity
android:name=".Activity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.DELETE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="package" />
</intent-filter>
</activity>
This will call the activity.
Related
For a project I have encountered a very strange issue:
Deeplinks have been working very well for the last year, but recently (since the beginning of January-2019) we have been getting complaints from our users that deeplinks have stopped working (some say 9 out of 10 time).
We have not changed any of this code and have great difficulty reproducing this issue.
Even stranger, in the sparse times that we do encounter the issue ourselves, the android OS does not even show our app as an option through the 'open with'-dialog. This suggest to us that the OS sometimes forgets that the app has intent-filters registered in its Manifest.
Restarting the app appears to fix this and deeplinks start working again.
The app also seems to work every time we do a new build from Android Studio, which makes it very hard to reproduce.
Our manifest has a specific activity that handles deeplinks:
<activity
android:name="com.company.DeepLinkActivity"
android:noHistory="true"
android:launchMode="singleTask">
<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:host="ideal-payment"
android:scheme="com.company.ideal" />
<data
android:host="ideal-payment"
android:scheme="com-company-ideal" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="${appLinkIdealHost}"
android:pathPrefix="/ideal-betaling/landingpage"
android:scheme="https" />
</intent-filter>
<intent-filter android:autoVerify="true">
...
</intent-filter>
<intent-filter android:autoVerify="true">
...
</intent-filter>
</activity>
We thought it might have something to do with the autoVerify not being accessible, but then the OS should show the 'open with'-dialog, which does not happen when the issue surfaces.
Is there someone that has encountered a similar issue? Any help or suggestions would be greatly appreciated.
When app is stopped for example with an exception or when user have force stopped it from settings or in some devices when user removes app from history (or from tasks) the app will be force stopped automatically (which is not a good choice from manufacturer) when app is in stopped state its manifest intentFilter will not be used (when app is first installed and never opened also it is in this phase)
While in stopped state, the application will not run for any reason,
except by a manual launch of an activity, or an explicit intent that
addresses an activity ,service or broadcast.
https://riptutorial.com/android/example/30592/android-stopped-state
Most of Android versions you mentioned was 8 or grater thus below quotation also may be useful but this is for services and broadcast receivers.
Whenever an app runs in the background, it consumes some of the
device's limited resources, like RAM. This can result in an impaired
user experience, especially if the user is using a resource-intensive
app, such as playing a game or watching video. To improve the user
experience, Android 8.0 (API level 26) imposes limitations on what
apps can do while running in the background.
https://developer.android.com/about/versions/oreo/background
Can you specify the version of android OS ? because android:autoVerify="true" works only on Android 6.0 and higher to cause the system to attempt to verify all hosts associated with the URLs in any of your app's intent filters.
these two entries also look strange to me, not sure what you are trying to accomplish there:
<data android:host="ideal-payment" android:scheme="com.company.ideal" />
<data android:host="ideal-payment" android:scheme="com-company-ideal" />
this is far from being ideal, because those hosts and schemes are both invalid, see data-element.
I would assume, based upon all the code which obviously had been withheld... that other intent-filter might also feature duplicate data elements, which would need to be moved into separate intent-filter, of which an activity element permits several. set android:autoVerify="true" on all these intent-filter and then closely review the logcat after the package installation.
Great news, we were able to find a solution.
The issue originated from an older version of the Chrome browser.
https://bugs.chromium.org/p/chromium/issues/detail?id=935864
After the release of version 73.0.3683.90 a few days ago, the issue has gone away.
Thanks Google :D
I am making an app and want to know when the app is uninstalling. For doing it, I used BroadcastReceiver but I don't know where is my code is wrong? (when my app is uninstalling, BroadcastReceiver can't receive any message about uninstalling)
It's my app's Manifest:
<receiver android:name="receiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="android.intent.action.PACKAGE_DATA_CLEARED"/>
<action android:name="android.intent.action.PACKAGE_INSTALL"/>
<action android:name="android.intent.action.UID_REMOVED"/>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<action android:name="android.intent.action.MEDIA_REMOVED"/>
<action android:name="android.intent.action.MEDIA_BAD_REMOVAL"/>
<action android:name="android.intent.action.BATTERY_OKAY"/>
<data android:scheme="com.example.testpermission"/>
</intent-filter>
You cannot get an event when your own app is uninstalling. See here. There is also a post on the subject here.
You can't, but if you have second installed application on the device - you can get notification via that application about the uninstallation of the first one (as far as I remember).
I believe that the application cannot monitor its own uninstall from two reasons:
It will make it much harder to uninstall application (some evil apps might even try to do something bad when their application is being removed).
If you remove application - you cannot run it, or send it events! The app should be closed for clean deletion.
About how to do it from second app:
Your second app should be a receiver to the ACTION_PACKAGE_REMOVED event (read about BroadcastReceiver, and see: http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_REMOVED)
I want to write an app that allows me to remotely start downloading a torrent on my desktop from my phone. How can I change android to open magnet links with my app? I'm trying to find a non-browser specific solution that can be executed on install without the user having to go through settings.
EDIT:
Something like this?
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="magnet" />
<data android:host="*" />
<data android:mimeType="application/myApp" />
</intent-filter>
I'm trying to find a non-browser specific solution that can be executed on install without the user having to go through settings.
Im not quite sure I understand what exactly you are trying to do with links. But I can tell you that it probably isn't going to work the way you want it on any stock devices. There is no mechanism within the system to let your application start doing anything right after it is installed. At the very least the user is going to have to choose to use your application to handle whatever links you are trying to override.
I need to bind some phone HW button to start my application.
It should be done from the code of the application or when installing it.
Is it possible in Android?
You can't bind an application to a key like creating shortcut keys in desktop applications.
If your app is not running then only way it can be invoked other than manual press on launcher icon, is by Broadcast Receivers only. But no key press is broadcasted in Android.
One way to achieve this by running a Service in foreground which watches for Key Presses and can initiate your app when specific Key combination is pressed. But not recommended because user may not like this.
Declare this in your manifest.xml file
<activity android:name=".youractivity">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.MONKEY" />
</intent-filter >
</activity>
No, you can't do that as far as I know and more importantly, even if you could, you shouldn't - it would be terribly UX. The user expects the hardware buttons to perform a certain function, overriding that sounds like a very bad idea.
Imagine if any app you would install could just change what your home button does...
Greets,
Made some app on android. I for the life of me can't get it to install on the phone as a stand alone application. It runs fine when I deploy from eclipse but never remains on the device. any idea whats happening?
I put the apk file on a web server, went to the address downloaded and installed but still it wasn't to be found.
I'm lost!
Make sure your application manifest defines an activtity with a category of LAUNCHER. For example:
<activity android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Otherwise, the Android apps screen won't pick it up.