좋아, 나는 해결책을 발견했다.
이
앱이 폐쇄 또는 배경에있을 때 나는 AndroidManifest.xml을
<activity
android:name=".ActivityXPTO"
android:screenOrientation="sensor"
android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="ACTIVITY_XPTO" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
에서 응용 프로그램
{
"registration_ids": [
"XXX",
...
],
"data": {
"id_offer": "41"
},
"notification": {
"title": "This is the Title",
"text": "Hello I'm a notification",
"icon": "ic_push",
"click_action": "ACTIVITY_XPTO"
}
}
서버로부터 전송있어 JSON과 사용자가 클릭입니다 알림에서 내 ActivityXPTO를 열어 오직해야 할 id_offer를 검색합니다.
public class ActivityXPTO extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
String idOffer = "";
Intent startingIntent = getIntent();
if (startingIntent != null) {
idOffer = startingIntent.getStringExtra("id_offer"); // Retrieve the id
}
getOfferDetails(id_offer);
}
...
}
그게 전부예요 ...
몇 가지 코드를 공유 할 수 있습니까? 내 앱에서 비슷한 점이 있지만 GCM을 사용하고 있습니다. 통지를받는 서비스에서, 나는 Intent에 여분의 문자열을 추가하고 이것을 사용하여 어떤 프래그먼트를 열어야 하는지를 알 수있다. – Vucko
나는 어떤 도움도 필요 없어, 내 애플 리케이션이 작동 :) 당신이 그것을 고쳐 준 당신을 위해 좋은 – Vucko
그것을 해결 했습니까? 나는 같은 문제를 가지고있다. 나는 targetActivity를 시작했지만 의도로부터 추가 정보를 얻지 못했습니다. 어떤 해결책이 있습니까? –