So, what I need here is to send data from App1 to App2. I've tried with simple code that I've made, but something is wrong here. I want to make a simple input on 1 editText in app1 then it will be received by app2.
Example :
App1 : EditText -> I input 'Hello!'
Then
App2 : TextView -> 'Hello!'
But what happens next, the textview in App2 does not show anything. What's wrong here?
These are my code that I've tried.
My Application 1:
secondAppButton = (Button)findViewById(R.id.secondAppButton);
namaEditText = (EditText)findViewById(R.id.namaEditText);
secondAppButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String nama = namaEditText.getText().toString();
Intent secondApp = getPackageManager().getLaunchIntentForPackage("com.example.yosua.myapplication2");
Bundle bundleApp = new Bundle();
bundleApp.putString("namaOrang", nama);
secondApp.putExtras(bundleApp);
startActivity(secondApp);
}
});
My Application 2:
namaDariApp1 = (TextView)findViewById(R.id.namaApp2);
String nama;
Intent intent = getIntent();
Bundle extras = intent.getExtras();
nama = extras.getString("namaOrang");
namaDariApp1.setText(nama);