2011-10-25 95 views
1

我開發了一個小工具。它包含圖像按鈕。 我可以選擇一個城市名稱(在按鈕中),它會打開我開發的另一個應用程序,它將在地圖上顯示上述城市。小工具開始活動

我創建活動和窗口小部件,但不知道如何啓動從插件的應用程序,以及我們如何可以通過城市名稱的申請

+0

沒有必要每次:)打開一個新的應用程序:)。只需打開或啓動新的應用程序活動 – Sameer

+0

抱歉,無需編輯文本............ – jibysthomas

回答

1

最後我找到了辦法

Intent theActivity = new Intent(Intent.ACTION_MAIN) 
.addCategory(Intent.CATEGORY_LAUNCHER) 
.setComponent(new ComponentName("your.pkgname", "com.pkgname.ScreenName")); 

這種開放與指定頁面

0

您可以通過bleow從小窗口打開的應用畫面代碼...以及從窗口小部件到應用程序的傳輸數據...您需要首先將數據保存到首選項,然後在應用程序中使用它。

public class WatchWidget extends AppWidgetProvider { 

    public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) 
    { 

     Intent intent = new Intent(context, show.class); 
     PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); 

     RemoteViews remoteViews; 
     ComponentName watchWidget; 
     remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_layout); 
     remoteViews.setOnClickPendingIntent(R.id.root, pendingIntent); 

     watchWidget = new ComponentName(context, WatchWidget.class);