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.
Related
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).
Hello I require some advice on how to approach this problem,
bear with me as I am still new to android.
I have an activity that opens on application start and requires some information from the user, but next time the user opens the app, i want the application to open a different activity that will display the various information.
Kind of like facebooks app, where when you first run it, you have to login, and only then next time you run the app you are guided straight to the feed.
Any ideas how one could do this efficiently?
UPDATE: Ive stored the information via shared preferences and am now using a controller activity that decides which step to take.
So, Controller activity runs on start up, and decides whether to show a log in screen or whether to go straight to the information. But now im encountering a problem where i end up opening a blank activity (the controller) and then another ontop of that ( the decided activtiy). I dont want the blank activity to show, so its kinda of like a background process, any ideas?
Ideally you would have a main activity like a controller. Use a SharedPreference object to keep track of whether the user is logged in or not. So back in your main activity, read this value and if it is set go to your news feed activity else show a login screen activity. (as you do the check and redirection, you can show a progress dialog)
links for SharedPreferences
MobTuts
Android Developer
Lets say you have a web app related Android app that requires the user to login in order to use it. The user logs in, in the Login screen activity and then proceeds to other activities. Each time the user starts an Activity, the app checks his login credentials again (The credentials are stored in a central database somewhere).
As the user jumps from one activity to another, lets pretend that the user's login credentials are revoked from the service. The next time the user visits an Activity, the app will see that he no longer has access. The app should now kick the user back to the login screen Activity.
But since there is already a stack of Activities that the app has created as the user used the app, how do you get the login screen. Do you kill/destroy all Activities until you reach the login screen Activity (which should be the Activity at the bottom of the stack for the app)?
Or do you start a new Login Screen Activity and go straight to that?
Or should I call the Login Screen Activity with the FLAG_ACTIVITY_CLEAR_TOP passed through the intent?
After the user is able to login the second time (lets say he got his credentials reinstated), if the Activity is now the only one in the stack, pressing the back button will take him out of the App, as opposed to going back to what he was doing before having his credentials revoked. What is the best approach to this?
My personal choice is to set up all of your activities (besides the login activity, of course) to check the user's credentials in onResume() (I do this by inheritance, with all of my Activities inheriting from an abstract AuthorizedActivity, but do what works for you). If the user does not have credentials (either because they don't have them or they've been revoked) then I startActivityForResult() the login activity. If the LoginActivity returns a valid user, all is well. If the user is a valid but different one from who was logged in before, I take them to my root activity with FLAG_ACTIVITY_CLEAR_TOP. pressing the back button from the loginActivity does them no good, as the app will bounce them straight to home.
I find that the approach gives me flexibility in deciding when and how I will check/revoke credentials, even if they leave (briefly) the application.
Login screen activity with FLAG_ACTIVITY_CLEAR_TOP will work but will remove all of the user's history. Do you care if they renew their credentials and then press back? Should that preserve their history?
You may consider FLAG_ACTIVITY_SINGLE_TOP and FLAG_ACTIVITY_NO_HISTORY for the login activity.
If you want all previous tasks to redirect to the login screen, you'd make sure to do the check in onResume so that they can't go back through the stack after having permission revoked.
Keep in mind that you can also set these flags on the <activity> element in the manifest.
I am writing an application in Vaadin that searches for results. A form is used to specify the criteria and a table is used to represent the results.
I also want to show the amount of results found in a Window.Notification of Vaadin.
My problem is that I want the notification to stay there until the user clicks on it so it does not disappear after a few seconds.
If you just enter a large delay time, then if you don't click on these notifications and do several searches, all result notifications will come over each other. So if you then click on them to remove them, you will see the amount of results from your previous search.
This is what I want to avoid.
Notifications are added to the Window and as far as I can see, you can't get a reference to them to update them. So you can't change the current notification if there is already one present. After it is painted it is removed from the LinkedList<Notification> notifications of com.vaadin.ui.Window
One of the things I was looking at is how Vaadin closes the notification after you click on it so that maybe I can do the same before each search so that the previous notification is removed and the new search adds a new notification.
But so far I am unable to find how it is done.
A notification in html is shown as a div. So maybe there is a javascript I could call in Vaadin to remove that div?
Does anyone know how the timer works for closing the notification after the defined delay? Will this call a javascript that I could also call?
If the delay on the notification is -1, it has to be clicked on by the user. Unless the notification is of type TYPE_ERROR_MESSAGE, you have to create a notification object yourself:
Notification message = new Notification("Message", Notification.TYPE_HUMANIZED_MESSAGE);
message.setDelayMsec(-1);
getWindow().showNotification(message);
There is no mechanism in Vaadin to listen for hide events of notifications. You could create your own widget derived from VNotification to transmit this condition back to the server.
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.