У меня есть два приложения app1 и app2. И я хочу запустить активность app2 из app1. А затем вернитесь к активности в приложении 1 с некоторыми данными из приложения2. Но я могу вернуться к app1, но не смог получить данные.Получить данные из другого приложения в android
от App1:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, sampleText);
intent.setType("text/plain");
intent.setComponent(new ComponentName("com.example.app2","com.example.app2.MainActivity"));
startActivity(intent);
от app2:
Intent goBack = new Intent();
goBack.putExtra("result","asdaf");
setResult(RESULT_OK, goBack);
finish();
манифест App1:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
манифест app2:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
Я не получаю удар по функции в приложении 1.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1) {
if(resultCode == RESULT_OK){
String result=data.getStringExtra("result");
TextView tv = (TextView)findViewById(R.id.textView3);
tv.setText(result);
}
if (resultCode == RESULT_CANCELED) {
//Write your code if there's no result
}
}
}
Что мне здесь не хватает ?. Есть ли какие-то настройки для этого?