Disable contacts button on android dailer app programmatically? - java

I am writing an app for a child's emergency phone that will allow them to call preprogrammed contacts by pressing a button on the app. The problem is that when it goes into the dialer app the user will have access to the contacts and the other settings available within the dialer. I want to prevent this. Essentially I want to have it so that the only button the child can press is the End Call button which will stop the dialer activity and drop the phone back to my custom home app. Is this possible? Or will I have to replace the entire dialer app (which, it seems, would be less than a trivial solution).

Related

Android - How to resume the last activity when launched icon is clicked or when back button is clicked

I am working on a tracking application that use another third party application such as google map.
Lets assume my application has 4 activities ( act1, act2 , act3 and act4 ).
on act3 activity i am calling google map application to calculate the distance and view the routing. But once i clicked on the back button of the tablet, or go back to the home page and clicked on the launched icon, the act1 is displaying instead of act3.
However, my application is still running on background.
So my question here how can i make the application is opened the last activity which is act3 in our example, when the back button is pressed or when the launched icon is clicked.
Thanks,
Store the name of the running activity into shared preferences in the onPause of every activity (if you're exiting by pressing home button) or in onBackPressed (if exiting an activity by pressing back button).
Then create a launcher activity which reads the shared preferences and launches the specific activity.
Lastly remove the launcher activity from the activity stack so that the app doesn't go back to it on pressing back button.

How to navigate back to my app instead of going down the backstack?

Let's say the user presses a button which causes another activity to get launched. Now the user is in another activity. What flag do I have to add to the intent, so that the user returns to my app when pressing the back button instead of navigating down the back stack of the started activity?
From the documentation, "activities on the backstack are never rearranged."
Android documentation Tasks and BackStack
You do not have to add anything to the intent. When you navigate out of you app and start another activity to complete a task, the new activity becomes kind of like an extension of your app. Pressing the back button takes you back to your app. Read This

In Android, use the phone default Dialer to launch an Activity?

In my app, the user creates a 4 digit code that is stored as a Shared Preference. The user will make a call, and with the phone call in progress (after the call has been answered), and my app running in the background, is it possible to type that 4 digit code into the default Dialer on the phone and have that dialed-in code launch an intent that would launch an Activity in my app? If this is possible can anyone give me some suggestions as to how to achieve this?

Android Auto Message Sending

i want to develop an android application to locate a mobile no.Obviously it cannot be done without user approval.
Basically i need the GPS coordinates of the other user.So my idea is to, after selecting a contact from the list,when i click on locate Button a automatic message/notifaction is sent to the other user asking for his/her permission to Allow/Deny.Once the user clicks on the allow button an automatic msg will be sent to the locator giving the longitudes,latitudes of the mobile which i can locate using GPS
If I understood you well, on the receiving end, a Service will be monitoring for Events (on Bluetooth or Wifi) and should popup a dialog requiring user to accept or deny a transaction.
You can quite easily make an Activity that polls for Event (or better, make a bounded background Service Message your Activity when a new Event has been detected) and display a popup AlertDialog. If you design it this way you will need your Activity to be active and running (i.e. displayed).
If you need your application to get user attention even when your application is not displayed, you will not be able to do so: you can not (nor should) directly start an Activity from within a Service. You will have to use Notifications and/or a Toast message to unintrusively notify your user that something requires his/her attention. Notifications appear in the status bar and can be used to launch your Accept/Deny Activity.

Android - other app stealing my intent receiver?

I have an app which uses the ACTION_MEDIA_BUTTON intent with a BroadcastReceiver to control a music player. The user pushes a button on external hardware and it controls the in-app music player. The user can also HOLD DOWN the button and change the volume.
I recently downloaded another app which uses the headset button, and it takes over the media button intent from my app! So when this other app is open and I press the button, the other app will start running, but my app will think that the button is still pressed down so it will cycle the volume.
To summarize,
my app is open, supposed to be sole listener of media button intents
other app gets opened, it also wants to be sole listener of media button intents
button gets pressed with both apps open, control goes to other app
my app thinks the button is being held down, as it lost control as the button was pressed in down mode (I think). It then launches functions I don't want launched because it thinks the user has held down the button.
Is there any way I could make sure that while my app is open it's the sole receiver of this media button intent? Could I at least check to see if another app has taken over, so I can prevent unexpected behaviour?
Thank you for any help, I've never had apps not play nicely before!
You can alter your BroadcastReceiver's priority (make it something large, like 10000): it should then get the Intent first, and then you can pass it on to the other app.
I have a similiar issue. I believe, outside of the 'arms race' over the priorites mentioned, the only real solution is to close the other application. If you are releasing this application to other users, you could possibly give them a message telling them to close other media player apps and services.
In your manifest you can set the intent priority to the max value of an integer which is: 2147483647.
You should not however set your IntentFilter priority over 1000 as it tells you in the API docs. You can set the IntentFilter priority like so:
myIntentFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
I assume you should subtract one from the SYSTEM_HIGH_PRIORITY constant as the docs say the value must be less than SYSTEM_HIGH_PRIORITY.
Quote from docs about IntentFilter.setPriority(int):
Applications must use a value that is larger than SYSTEM_LOW_PRIORITY and smaller than SYSTEM_HIGH_PRIORITY.

Categories