0

I am working on this project which have no launcher activity.I want to show a toast to the user when application is installed on the phone.i am beginner in android. Do any body have any idea of how to do this? please do share the solution i shall be thankful.

IAmGroot
  • 13,760
  • 18
  • 84
  • 154
Usman Riaz
  • 2,920
  • 10
  • 43
  • 66
  • Installation of an app is done by the OS not by your app. the OS usually says "App Installed" or similar anyway.. So i dont see what the issue is. – IAmGroot Jun 04 '14 at 09:32
  • Actually i want to simulate an sms to user with some information like the default password . . .\ – Usman Riaz Jun 04 '14 at 09:35
  • If your app doesn't have a main/launcher `Activity` it's not going to be of any use to anyone - well not on later versions of Android anyway. In order for an Android app to be trusted it must be manually started by the user at least once. – Squonk Jun 04 '14 at 09:36
  • Shoot. My app also require to have no launcher icon :-( Seems like my project failed :-( – Usman Riaz Jun 04 '14 at 09:39
  • It's a change to provide better security and prevent malware. Unless a user manually starts your app it isn't considered trusted even if you have `BroadcastReceivers` registered in the manifest. Also, even if the user has launched an app in the past, if they `Force Stop` the app using Settings -> Apps, the system considers that to mean the user doesn't want that app to run ever again unless they manually start it. – Squonk Jun 04 '14 at 09:43
  • Its creeping me out .. . – Usman Riaz Jun 04 '14 at 09:45
  • Take a look at this 'http://stackoverflow.com/questions/7470314/receiving-package-install-and-uninstall-events' – Usman Riaz Jun 04 '14 at 09:48
  • Why? Do you you *really* want to write an app that users have little or no control over? I certainly wouldn't want your app on any of my devices and I'm quite happy with the added security. As for your linked question, that was asked in September 2011 - nearly 3 years ago. What was possible then isn't possible for the later versions of Android. – Squonk Jun 04 '14 at 09:50
  • Actually its not background running application. i want user to dial a certain number (Pin code) and after he make a call to that number app will be launched. – Usman Riaz Jun 04 '14 at 09:55
  • So I can not invoke my application or a part of application via some kind of system generated Event (Broadcast Receivers) ?? So how come they still want us to use their broadcast receivers if we can not use them ?\ – Usman Riaz Jun 04 '14 at 09:57
  • Can you please give me any link saying "If your app doesn't have a main/launcher Activity it's not going to be of any use to anyone - well not on later versions of Android anyway. In order for an Android app to be trusted it must be manually started by the user at least once." ?? – Usman Riaz Jun 04 '14 at 10:00
  • You CAN use `BroadcastReceivers` to 'listen' for system events (broadcasts) or any other type of broadcast event. The point is, you receivers will NOT be registered until the user has launced the app manually at least once. Without a main/launcher `Activity` a user can't manually launch the app. – Squonk Jun 04 '14 at 10:00
  • So did you get the big pic of what i am up to ?? can you give my any solution? User Install the app, receives sms with default pincode.make a call to that pincode to launch the app – Usman Riaz Jun 04 '14 at 10:03
  • Section 1.5 of this tutorial http://www.vogella.com/tutorials/AndroidBroadcastReceiver/article.html#broadcastreceiver_platformfilter – Squonk Jun 04 '14 at 10:03
  • Bingo.if your receivers are registered in AndroidManifest then yes, your app will still receive it. On the other hand, if you are registering via code (in service/activity), then the app won't receive it. – Usman Riaz Jun 04 '14 at 10:12
  • Sorry but I give up. What part of **"As of Android 3.1 the Android system excludes all receiver from receiving intents by default if the corresponding application has never been started by the user or if the user explicitly stopped the application via the Android menu"** do you not understand? It doesn't matter where your receivers are registered - if the user has never started your app (or has started it but later force stopped it), your receivers won't be registered. Without a main/launcher `Activity` your app cannot be started. – Squonk Jun 04 '14 at 10:19
  • Hmmm, looks like change of plans . . – Usman Riaz Jun 04 '14 at 10:21

1 Answers1

0

Its not possible Usman. Don't get distracted by following intents

Intent.ACTION_PACKAGE_ADDED
Intent.ACTION_PACKAGE_INSTALL

These are not sent to the package that just got installed i.e. your app :)

Naeem A. Malik
  • 995
  • 4
  • 19
  • Sorry i didn't get you. if i register these intents in my application would not be i notified when my app is installed ?? – Usman Riaz Jun 04 '14 at 09:41
  • take a look at this http://stackoverflow.com/questions/7470314/receiving-package-install-and-uninstall-events – Usman Riaz Jun 04 '14 at 09:49
  • Your app will get notifications when other packages will be installed or removed, but your app will not get a notification when it itself gets installed. – Naeem A. Malik Jun 07 '14 at 08:37