Como abrir um aplicativo do widget no Android?

Quando clicamos no widget naquele momento eu preciso abrir uma canvas de atividade (ou aplicativo). Como fazer isso?

3 Solutions collect form web for “Como abrir um aplicativo do widget no Android?”

Você precisa configurair um onClickpendingIntent no seu widget

Intent intent = new Intent(context, ExampleActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); // Get the layout for the App Widget and attach an on-click listener to the button RemoteViews views = new RemoteViews(context.getPackageName(),R.layout.appwidget_provider_layout); views.setOnClickPendingIntent(R.id.button, pendingIntent); 

Veja isso

Processando mais do que um button, clique no widget do Android

Inclua esse código no método onUpdate () da sua WidgetProvider.

 for(int j = 0; j < appWidgetIds.length; j++) { int appWidgetId = appWidgetIds[j]; try { Intent intent = new Intent("android.intent.action.MAIN"); intent.addCategory("android.intent.category.LAUNCHER"); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); intent.setComponent(new ComponentName("your Application package", "fully qualified name of main activity of the app")); PendingIntent pendingIntent = PendingIntent.getActivity( context, 0, intent, 0); RemoteViews views = new RemoteViews(context.getPackageName(), layout id); views.setOnClickPendingIntent(view Id on which onclick to be handled, pendingIntent); appWidgetManager.updateAppWidget(appWidgetId, views); } catch (ActivityNotFoundException e) { Toast.makeText(context.getApplicationContext(), "There was a problem loading the application: ", Toast.LENGTH_SHORT).show(); } } { for(int j = 0; j < appWidgetIds.length; j++) { int appWidgetId = appWidgetIds[j]; try { Intent intent = new Intent("android.intent.action.MAIN"); intent.addCategory("android.intent.category.LAUNCHER"); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); intent.setComponent(new ComponentName("your Application package", "fully qualified name of main activity of the app")); PendingIntent pendingIntent = PendingIntent.getActivity( context, 0, intent, 0); RemoteViews views = new RemoteViews(context.getPackageName(), layout id); views.setOnClickPendingIntent(view Id on which onclick to be handled, pendingIntent); appWidgetManager.updateAppWidget(appWidgetId, views); } catch (ActivityNotFoundException e) { Toast.makeText(context.getApplicationContext(), "There was a problem loading the application: ", Toast.LENGTH_SHORT).show(); } } } for(int j = 0; j < appWidgetIds.length; j++) { int appWidgetId = appWidgetIds[j]; try { Intent intent = new Intent("android.intent.action.MAIN"); intent.addCategory("android.intent.category.LAUNCHER"); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); intent.setComponent(new ComponentName("your Application package", "fully qualified name of main activity of the app")); PendingIntent pendingIntent = PendingIntent.getActivity( context, 0, intent, 0); RemoteViews views = new RemoteViews(context.getPackageName(), layout id); views.setOnClickPendingIntent(view Id on which onclick to be handled, pendingIntent); appWidgetManager.updateAppWidget(appWidgetId, views); } catch (ActivityNotFoundException e) { Toast.makeText(context.getApplicationContext(), "There was a problem loading the application: ", Toast.LENGTH_SHORT).show(); } } 

As páginas de desenvolvedores do Android paira Widgets de aplicativos possuem informações e um exemplo completo fazendo exatamente isso: http://developer.android.com/guide/topics/appwidgets/index.html

Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.