###前提・実現したいこと
AndroidStudioでBundleを使用してデータの受け渡しをしているのですが、Service(Activityではない)にデータをBundleで投げて、処理をバックグラウンドで行いたいのですが、そもそもActivity以外でBundleの受け渡しがうまくできません。どのようにコードを書けばうまく実装出来るのでしょうか。
###該当のソースコード
Andorid Studio(Java)
Java
1Activity側 2private String mParticipantsGroupName; 3 4Intent intent_remind = new Intent(Activity.this, Service.class); 5Bundle bundle = new Bundle(); 6bundle.putString("ParticipantsGroupName", mParticipantsGroupName); 7intent.putExtras(bundle); 8startService(bundle); 9 10Service側のクラス 11public void onCreate(){ 12 super.onCreate(); 13 14 Bundle bundle = new Bundle(); 15 /*必要なオブジェクト名やIDを受け取る*/ 16 mParticipantsGroupName = bundle.getString("ParticipantsGroupName"); 17}
###補足情報(言語/FW/ツール等のバージョンなど)
AndroidStudio 2.0を使用しています。
回答1件
あなたの回答
tips
プレビュー