Back to my application when call direction from google map in Android - android

I have an application get direction via google map. Example Activity A call google map:
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(myuri));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setClassName("com.google.android.apps.maps","com.google.android.maps.MapsActivity");
startActivity(intent);
It show
Image 1: http://flic.kr/p/eBnRCy
then show
Image 2: http://flic.kr/p/eBjGWn
How to from image 2, I can back again my application(Activity A), don't back again image 1. Thanks a lot.

You may try to hack it with Intent.FLAG_ACTIVITY_NO_HISTORY, which removes first Activity as soon as a second is opened. This will work if the two screens you put into question are two instances of Activity (even if they are the same class).

Related

How to handle back button in other application?

I have navigated to maps application from myapplication using following code
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
when i press back button in maps it navigates to my application.
When i minimize maps application and open maps from recently open list apps and press back button, My application is not opening.
Could any help me on this ?
Do i need to add any flags to intent to open my application in second case ? or any idea please suggest me..
It seems to me you should set android:alwaysRetainTaskState true in your root activity.

Google Maps navigation in Android not coming back to Recent Activity

i am working with Google Maps navigation in my Android application ...
When calling Google Maps navigation's Intent from MainActivity Google Map Showing route path completely in my device but now when press back button from Google Maps it close whole application instead go back to MainActivity so i need to go back my MainActivity on Back pressed in Map activity...
My code for calling map activity
String strURL = new StringBuilder()
.append("http://maps.google.com/maps?saddr=")
.append(src_lat).append(",").append(src_long)
.append("&daddr=").append(dest_lat).append(",")
.append(dest_long).toString();
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse(strURL));
intent.setClassName("com.google.android.apps.maps",
"com.google.android.maps.MapsActivity");
startActivity(intent);
Can any one help me ??? how to catch back pressed event from Google Maps navigation's Intent ...
You should use startActivityForResult(); and make sure your activity doesn't have any propertly like singleinstance or singleTop.

Start Google Navigation from another Activity without setting a location

This is probably really stupid of me but how do I start google navigation WITHOUT setting a location as a lot of issues seem to come from... When I try to do this it actually starts to run Google Navigation but then just keeps restarting the Activity... Essentially I was it to run just like when you click on Navigation like you would from a home screen... So with the list of destinations etc... I presume this is a different activity maybe? I've no idea, the intent I'm using is below,
Intent i = new Intent(Intent.ACTION_VIEW);
i.setClassName("com.google.android.apps.maps", "com.google.android.maps.driveabout.app.NavigationActivity");
getContext().startActivity(i);
Finally found what Activity it is that needs starting!!!
Intent i = new Intent();
i.setClassName("com.google.android.apps.maps","com.google.android.maps.driveabout.app.DestinationActivity");
startActivity(i);

Calling another application from intent kill my running application

Hello I'm using built in Google Map to show route to user.
When I click on get route button I have written the following code.
String mapURL="http://maps.google.com/mapssaddr="
+GlobleVeriable.getCurrentLocation().getLatitude()+","+GlobleVeriable.getCurrentLocation().getLongitude()+"&daddr="+restaurant.getLatitude()
+","+restaurant.getLongitude();
Intent i=new Intent("android.intent.action.VIEW",Uri.parse(mapURL));
startActivity(i);
This code Works fine and also displayed route from current location to destination location..
When I come back to my application from Google Maps ,my application start from first.
Can any one suggest me what to do?
Can you please try the code below
String uri="http://maps.google.com/mapssaddr="
+GlobleVeriable.getCurrentLocation().getLatitude()+","+GlobleVeriable.getCurrentLocation().getLongitude()+"&daddr="+restaurant.getLatitude()
+","+restaurant.getLongitude();
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, uri);
intent.setClassName("com.google.android.apps.maps",
"com.google.android.maps.MapsActivity");
startActivity(intent);
It's just the average Android behavior. What you can do is to save the current state of the application to some file, right before starting the Google Maps activity. On resume, you can load that file and restore the application manually.
I think it's the only way. It's been a while since I browsed the Android documentation. I do remember something like "... the operating system may terminate your application at any time if inactive, so it's the developer's responsibility to save any user-sensitive information before the application goes inactive".
I'd save within the onPause() method, and load within onResume().

Android Launching or bringing to front another application via Intent

Im having trouble getting this to work, hereĀ“s a quick overview of the idea.
First, I cant change the logic behind this, it was a specific requirement from the customer, I realize that with any tool such as AnyCut it could be bypassed but that doesnt matter really.
My customer offers a suite of apps, the idea is that all applications bellonging to the suite would be launched from a "Dashboard app", so that I only show the Dashboard app in the main launcher and not all app icons.
Lets take two Apps to get the idea solved. The Dashboard App (A) and the Recieving App (B).
I want to establish an intent filter (I think) on app B so that whenever I go into app A, and click the app B icon the app will be either launched or started from where it let of (brought to front).
Is this even possible? If so, how can I do it? I managed to get it to launch by specifically launching one activity in the app using:
Intent i = new Intent();
i.setClassName("PACKAGE_NAME","SPECIFIC_CLASS");
startActivity(i);
But that isnt the behaviour that I want, as it always starts app B in the same spot.
Thanx in advance,
Stefano
Edit: Added some new information. I was taking a look at the DDMS.
If I launch the application from scratch through the main Android launcher the intent is exactly the same as when I leave the home button pressed and then only bring the app to front, what ever activity im in. So I was trying to reproduce, unsucsesfully until now, this intent.
INFO/ActivityManager(1292): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.package/.uiPackage.Activity}
This is how AnyCut does it
Intent { act=android.intent.action.VIEW flg=0x10000000 cmp=com.example.package/.uiPackage.Activity bnds=[125,242][235,360]}
Any idea how I could go about creating that exact same intent? I cant even find that flag in the Intent API.
Figured it out, this is how I did it.
Intent i = new Intent();
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setAction("android.intent.action.VIEW");
i.setComponent(ComponentName.unflattenFromString("com.example.package/com.example.package.activityName"));
startActivity(i);
I'm not quite sure I'm following the expected results you want to see, but the following would launch the app from the dashboard and remove the dashboard from the activity stack leaving the selected app running:
Intent i = new Intent();
i.setClassName("PACKAGE_NAME","SPECIFIC_CLASS");
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
I believe this should start the app as if you were starting any other app.
Please add more information on your logic if this is not what you are looking for.
I think that when you switch activities android's default action is to sort of pause or hold the activity in its state the user left it in last. I know there is a way to make it so that the state is not saved when switching activities but I cant remember it off the top of my head.

Categories

Resources