navigation callback? - Android Software Development

I launch google navigation like this trough my app
Intent scanIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=new york city"));
startActivityForResult(scanIntent, 0);
is there any way to know if the user has reached the destination?

Related

Click on Notification does not work as expected... (see screencast!):(

Hi guys,
first of all - Merry Christmas!!!
I have a strange problem here and spent too many hours figuring out what the problem might be. I definitely need your help here now... I'm pretty sure this is very easy to fix... if you know how...
I develop a little free app for German O2 customers so that they can send their 50 free Web-SMS directly from their Android phone and not only via web interface like O2 wants them to. These SMS are sent in the background using a service. This service generates notifications (e.g. Message sent successfully, Login successful/failed,...)
When I click on that notification the app should open and then display the notification message. This works pretty fine as long as the app is visible (foreground/active). When putting the app into the background it's getting launched as well, but it doesn't display the message... then, when I hold down the HOME-Key and select the app... the message gets displayed.
See the following video... to show you what I mean...
http://dl.dropbox.com/u/1676562/NotificationIssue.mov
I'm pretty sure it has something to do with the Fflags for my intent, so here's my code:
Setting the notification:
Code:
// The PendingIntent to launch our activity if the user selects this
// notification
final Intent notificationIntent = new Intent(ManagerFactory
.getMasterActivity(), MailerActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
Log.d(TAG, "Set new message to Notification: " + p_message);
notificationIntent
.putExtra(Constants.NOTIFICATION_EXTRA_KEY, p_message);
Log.d(TAG, "Setting requestCodeToFixNotificationBug: "
+ s_requestCodeToFixNotificationBug);
final PendingIntent contentIntent = PendingIntent.getActivity(
ManagerFactory.s_service, s_requestCodeToFixNotificationBug++,
notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(ManagerFactory.s_service, p_tickerText,
p_message, contentIntent);
Reacting on the incoming intent:
Code:
/*
* (non-Javadoc)
*
* @see android.app.Activity#onNewIntent(android.content.Intent)
*/
@Override
protected final void onNewIntent(final Intent p_intent) {
// when called via notification, get the extras
Log.d(TAG, "Called onNewIntent...");
final Bundle extras = p_intent.getExtras();
Log.d(TAG, "Extra: " + extras);
if (extras != null
&& extras.getString(Constants.NOTIFICATION_EXTRA_KEY) != null
&& !extras.getString(Constants.NOTIFICATION_EXTRA_KEY).trim()
.equalsIgnoreCase("")) {
Log.d(TAG, "Extra:"
+ extras.getString(Constants.NOTIFICATION_EXTRA_KEY));
this.showLongMessage(extras
.getString(Constants.NOTIFICATION_EXTRA_KEY));
}
}
Would be great if someone was able to help me...
Sascha
Does onNewIntent get called? If it does, try stepping through the code with a debugger. Also try setting a unique value to the Intent's data field like System.currentTimeMillis().
Doing this fixed a similar issue for me.

[Q] Start intent from widget

I am making an app that also has a widget attached. on the widget I want to have a button that wen clicked will open the app. So I have this:
RemoteViews views = new RemoteViews("com_ice", R_layout_widget);
Intent configIntent = new Intent(context, ICE_class);
PendingIntent configPendingIntent = PendingIntent.getActivity(context, 0, configIntent, Intent_FLAG_ACTIVITY_NEW_TASK);
views_setOnClickPendingIntent(R_id_details, configPendingIntent);
The button's ID in the widget's XML file is "details" and the app I want to open has the class ICE. The problem is that when I press the button nothing happens. Any help is appreciated.

AppWidget problem when process is running

So I'm programming a application with a widget.
On my widget I got a button that starts an activity with a PendingIntent. This activity that's getting launched isn't my main activity.
Now when I'm doing it like this I get a Strange problem:
- Launching App as normal over appdrawer -> main activity opens up
- Pressing Home or Back button
- Add widget to homescreen
- Click button on widget -> nothing happens!
If I force stop my application before adding the widget to the homescreen, a click on the button on the widget opens up the activity like it should. Now I can also launch my main activity, pause it and the widget still works. So the widget only fully works if I my application isn't running in the background while adding the widget.
Has anyone of you experienced something like that?
Thank you in advance!
it is really dependent on how your onClickListener is added to the button. ive had problems where the first widget i create doesnt have the onClickListener attached but the second one will. do you mind sharing your code that you use to attach the onClickListener?
here is mine:
Code:
/** Called when the activity is first created. */
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
Toast.makeText(context, "onUpdate()", Toast.LENGTH_SHORT).show();
//super.onUpdate(context, appWidgetManager, appWidgetIds);
//attach an onClick intent to the layout
final Intent onClick = new Intent(context, GITextCloud.class);
onClick.setAction(LAUNCH_GMAIL_GAPPS);
PendingIntent onClickPending = PendingIntent.getBroadcast(context, 0, onClick, 0);
RemoteViews rv1 = new RemoteViews(context.getPackageName(), R.layout.gitc_html);
rv1.setOnClickPendingIntent(R.id.full_widget, onClickPending);
for (int appWidgetId : appWidgetIds) {
appWidgetManager.updateAppWidget(appWidgetId, rv1);
}
}
My code is really almost the same. Just that I need PendingIntent.getActivity instead of getBroadcast.
what flags do you set for your intent? cause if your activity is already running and thats when the button wont work it could be that you need a Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT or some other flags in the PendingIntent
try setting onClick.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) or what ever your Intent is called. i think the fact that your widget and your app are going to be seperate programs means they must start in different threads. cause not all widgets need an Activity running to function
I got it now! I somehow managed to screw up my remoteviews, they didn't got updated properly.
Anyway, thanks a lot for your answers

Open Maps and show a place.

Hello, im trying to program an intent for open google maps and show a place.
I want to select the place by coordinates.
I have tested
Code:
String uri = "geo:0,0?q="+address;
context.startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri)));
It works fine and show the location of the address with a marker
But using coordinates:
Code:
String uri = "geo:"+ lat+ "," +log;
context.startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri)));
Is the zone is shown but there's no marker for showing the exact place.
how can I place the marker in the intent (with a label if possible)
Thanks in advance.
i take it you've seen this http://developer.android.com/guide/appendix/g-app-intents.html
it looks like it says that the use of the geo tag is underdevelopment at the moment. it might just be that the implementation of this uri is broken.
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("geo:0,0?q=37.423156,-122.084917 (" + name + ")");
startActivity(intent);

Problems with using multiple widgets in a single app

I have multiple widgets provided by one app, and thus multiple classes that extend AppWidgetProvider. The idea is that every widget contains a Button, which starts a Service when pressed. This Service runs a bit of code and then stops. Now for the problem: for example, I have a Widget1a and a Widget1u. These widgets look like each other, but each widget does a slightly different thing. If I place a Widget1a on the homescreen and press it, a Service is started and the code that this Service should run is run, as it should be. Now I place a Widget1u on the homescreen, and suddenly Widget1a stops working and doesn't do anything when I press it. If I place a second Widget1a on the homescreen both Widget1as work again, but now Widget1u is disabled and doesn't respond when I press it. In short: it seems that at any particular time only one type's code works when it is pressed (and if there are multiple instances of the same type on the homescreen all of these instances will work, but no instances of any other widget of my app will do anything when pressed).
The code in the AppWidgetProvider of each widget is pretty basic. It merely contains an overrided onUpdate-method. It creates an Intent to start a Service that I previously created, this is then used to create a PendingIntent which is used by setOnClickPendingIntent to make sure it can be activated by a Button in the widget. Each widget makes, when its Button is pressed, a slightly different Intent so that a certain Service is executed slightly differently. So this only works for the instances of 1 widgettype at a time, namely those of which an instance was added to the homescreen most recently.
Why do all my app's other widgets stop working when I add a widget of a different type to my homescreen? Does anyone know more about widgets or how I can make sure that each widget keeps doing its job when I add a new one from the same app to the homescreen?
Here is the onUpdate method of one of my AppWidgetProviders for one of my widgets. All widgets operate similarly and I know I used a lot of copypasting which is a bad programming habit but it didn't seem to really want to work otherwise.
Code:
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
// Create an intent to launch the service
Intent serviceIntent = new Intent(context, SendService.class);
//I just put some extra data here to be used by the Service which wil eventually get this Intent and thus the data inside
serviceIntent.setData(Uri.parse("uri::somethingrandomandunique"));
serviceIntent.putExtra("Lamp", "1a");
// PendingIntent is required for the onClickPendingIntent that actually
// starts the service from a button click
PendingIntent pendingServiceIntent =
PendingIntent.getService(context, 0, serviceIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
// Get the layout for the App Widget and attach a click listener to the
// button
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget1a);
views.setOnClickPendingIntent(R.id.button1a, pendingServiceIntent);
// super.onUpdate(context, appWidgetManager, appWidgetIds);
ComponentName componentName = new ComponentName(context.getPackageName(), Widget1a.class.getName());
appWidgetManager.updateAppWidget(componentName, views);
}
So what am I doing wrong?

Categories

Resources