2011-01-30 10 views
0

Androidデバイスでは、ホーム画面の空き領域をクリックするか長押しすると、ホームアクティビティ/ダイアログに追加され、ホーム画面を表示するためのさまざまなオプションから選択できます。Androidで「Add to Home」アクティビティを呼び出す方法は?

私はステータスバーで通知を受け取りました。その通知がクリックされたときに何をしたいのですが、私はAdd to Homeアクティビティを開きたいと思います。

通知は正常に機能しています。

クリックしたときに通知のターゲットとして設定できるアクティビティname.classはありますか?

Android Launcher source codeを確認しました。

が、私はこれを見つけた:

if (mWorkspace.allowLongPress()) { 
1747    if (cellInfo.cell == null) { 
1748     if (cellInfo.valid) { 
1749      // User long pressed on empty space 
1750      mWorkspace.setAllowLongPress(false); 
1751      showAddDialog(cellInfo); 
1752     } 
1753    } else { 
1754     if (!(cellInfo.cell instanceof Folder)) { 
1755      // User long pressed on an item 
1756      mWorkspace.startDrag(cellInfo); 
1757     } 
1758    } 
1759   } 
1760   return true; 

ほとんど確かにshowAddDialog(cellInfo)は、ホーム画面に追加が表示されます。

上記の私の要求に対してこれをどのように実装するかについてのアイデア。

+0

ユーザーは自由に別のホーム画面を使用することができます。そして、この仕組みはおそらくホームスクリーンに依存しているでしょう。 – Falmarri

答えて

0

あなたは以下のようないくつかのことを使用することができ、通知をクリックしたときに、「ホームアクティビティーに追加」を開始するために何かを導き出すことができ、このから希望

    NotificationManager mNoficationManager; 
      mNoficationManager = (NotificationManager) mCntxt.getSystemService(Context.NOTIFICATION_SERVICE); 
      Intent intent1 = new Intent(); 
    ComponentName comp = new ComponentName("YOURPACKAGE TO START","YOUR ACTIVIT TO BE STARTED"); 
    intent1.setComponent(comp); 
    intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 


    /* SEND NOTIFICATION */ 
    PendingIntent pi = PendingIntent.getActivity(mCntxt, 0, intent1, 0); 
    Notification n = new Notification(); 
    n.flags = Notification.FLAG_ONGOING_EVENT; 
    n.defaults |= Notification.DEFAULT_SOUND; 
    n.tickerText = "some text for tickering"; 
    mNoficationManager.notify(some int value for your notification id, n); 

    int icon = mCntxt.getApplicationInfo().icon; 
      Notification notification = new Notification(icon,"some text title",System.currentTimeMillis()); 
      notification.setLatestEventInfo(mCntxt, "Some text", " some text ", pi); 

    notification.defaults |= Notification.DEFAULT_SOUND; 
    mNoficationManager.notify(NOTIFICATION_ID, notification); 

、活動を開始します。

関連する問題