2013-05-22 6 views
3

Android 앱을 개발 중입니다. REST API를 구문 분석하여 앱에 푸시 알림을 보낼 수 있습니다. 하지만 올바른 화면을 열려면 REST API에서 조치 필드 (의도)를 보내야합니다. 현재 홈 화면을 열었습니다.android에서 활동의 인 텐트를 호출하는 방법은 무엇입니까?

지금은 그냥 홈 (메인 화면) 괜찮나 내가

내 안드로이드 매니페스트 파일 구문 분석 REST API를 통해 브랜드 활동 클래스 (test.mm.brand)를 엽니 다 의도를 지정할 수 있습니다을 열어 다음과 같습니다.

<activity 
    android:name=".MofActivity" 
    android:label="@string/app_name" > 
    <intent-filter> 
     <action android:name="android.intent.action.MAIN" /> 
     <category android:name="android.intent.category.LAUNCHER" /> 
    </intent-filter> 
</activity> 

<activity android:name="test.mm.brand" /> 
<activity android:name="test.mm.CustomizedListView" /> 
<activity android:name="test.mm.HallofFame" /> 
<activity android:name="test.mm.VideoList" /> 

REST 요청이 추가 여기 Parse Android Notification - responding to payloads

을 주어진 당신은 통지를 얻기 위해 수신기를 만들 필요가

curl -X POST -H "X-Parse-Application-Id: ntItEUY1LZ949R9zfTWDuZORE6dnjICxOni9L9nU" -H "X-Parse-REST-API-Key: dwYZ2DeKutwtswDgWTYkboIw6hRplwSNDR20GiMt" -H "Content-Type: application/json" -d '{ "where": { "deviceType": "android" }, "data": { "alert": "Your suitcase has been filled with tiny robots!", "action": "test.mm.brand", "title" : "dddd" } }' https://api.parse.com/1/push 
+0

RestAPI를 통해 어떤 정보를 보내시겠습니까? – asloob

+0

님이 질문에 답변을 추가했습니다. – Vidya

+0

알림을 어떻게 작성합니까? 동일한 REST API 요청을 통해 – asloob

답변

4

매니페스트

<receiver android:name="test.mm.MyCustomReceiver"> 
<intent-filter> 
    <action android:name="test.mm.brand" /> 
</intent-filter> 
</receiver> 

이 클래스를 생성

public class MyCustomReceiver extends BroadcastReceiver { 
private static final String TAG = "MyCustomReceiver"; 

    @Override 
    public void onReceive(Context context, Intent intent) { 
    try { 
     String action = intent.getAction(); 
     if(action.equalsIngnoreCase("test.mm.brand") { 
     Intent intent = new Intent(context, test.mm.brand.class); 
     i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
     context.startActivity(i); 
     } 

    } 
    } 
} 
+0

예. 하지만 REST API를 통해이 작업을 수행하려고합니다. – Vidya

+0

REST API를 통해 정보를 보낼 수 있으며이 정보를 사용하여 리디렉션 할 기본 활동을 결정할 수 있습니다. – asloob

+0

ok. 그러나 REST API의 조치 필드는 의도를 취합니다. 우리는 앱 코드에서이를 수행 할 필요가 없습니다. REST API를 통해 인 텐트를 어떻게 트리거합니까? – Vidya

관련 문제