Reputation: 33
Basically I'm using the following code to open Google Navigation within an activity
String uri = "google.navigation:ll="+LAT+","+LNG;
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(i);
Where LAT & LNG
are the coordinates of a specific destination. Basically what I'm trying to do is once the destination is reached, an action would be triggered where the navigation activity closes and return to the same Class it was opened in.
Any help would be much appreciated.
EDIT: i guess since the activity i opened "Google Navigation" is beyond my control it is impossible to close it from within the app. So the best solution would be to reopen the current activity once the destination is reached.
Appreciate all the answers.
Upvotes: 3
Views: 7359
Reputation: 10274
use Finish()
method to kill your activity as
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(intent);
finish();
Upvotes: 1
Reputation: 1
Maybe you should put a thread to compare the destination and current location. Like this:
Thread thread = new Thread(){
@Override
public void run() {
// TODO: Do your work here
myHandler.sendMessage(new Message());
}
};
create a handler and implementing the handleMessage method.
Handler myHandler = new Handler(){
@Override
public void handleMessage(Message msg) {
// TODO: finish the activity here
finish();
}
};
Upvotes: 0
Reputation: 1978
If you press your back button it will work !! don't finish() the previous activity. Dont call finish() when you are starting the intent. Once you finish with navigation press back button
Upvotes: 0
Reputation: 10969
Add Finish()
method to end up an activity@
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(i);
finish();
Upvotes: 0