2010-08-28 17 views
10

जब हम उस समय विजेट पर क्लिक करते हैं तो मुझे एक गतिविधि स्क्रीन (या एप्लिकेशन) खोलने की आवश्यकता होती है। ऐसा करने के लिए कहां? http://developer.android.com/guide/topics/appwidgets/index.html:एंड्रॉइड में विजेट से एप्लिकेशन कैसे खोलें?

उत्तर

10
+0

पहला लिंक मृत। –

+0

साइड सवाल, क्या आप एक विशिष्ट ऐप के लिए गतिविधियों को निकाल सकते हैं? (शायद मुझे नहीं पता कि कौन सी कक्षा exampleActivity.class है) – RelativeGames

0

अनुप्रयोग विजेट के लिए Android डेवलपर पृष्ठों जानकारी और एक पूर्ण उदाहरण वास्तव में क्या कर रही है यह अपने विजेट पर एक onClickpendingIntent स्थापित करने के लिए

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); 

चेक की जरूरत है

5

इस कोड को विजेटप्रोवाइडर क्लास की अपडेटेट() विधि में शामिल करें।

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(); 
    } 

} 
+0

अद्भुत काम करता है! धन्यवाद शिवानंद दारूर –

+3

"आपका एप्लिकेशन पैकेज", "ऐप की मुख्य गतिविधि का पूर्णतः योग्य नाम" का अर्थ है 'intent.setComponent (नया घटक नाम (context.getPackageName(), MainActivity.class.getName()); ' –

संबंधित मुद्दे