AppA MainActivity.java
package iterator.ir.appa; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class MainActivity extends AppCompatActivity { Button buttonShow; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); buttonShow= (Button) findViewById(R.id.buttonShow); buttonShow.setOnClickListener(buttonShow_OnClickListener); } View.OnClickListener buttonShow_OnClickListener=new View.OnClickListener() { @Override public void onClick(View v) { Intent intent=new Intent(getBaseContext(),MessageActivity.class); startActivity(intent); } }; }
AppA AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="iterator.ir.appa"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MessageActivity"> <intent-filter> <action android:name="ir.iterator.AppA.MessageActivity" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> </application>
AppB MainActivity.java
package iterator.ir.appb; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class MainActivity extends AppCompatActivity { Button buttonShow; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); buttonShow= (Button) findViewById(R.id.buttonShow); buttonShow.setOnClickListener(buttonShow_OnClickListener); } View.OnClickListener buttonShow_OnClickListener=new View.OnClickListener() { @Override public void onClick(View v) { Intent intent=new Intent("ir.iterator.AppA.MessageActivity"); startActivity(intent); } }; }
References
https://github.com/mhdr/AndroidSamples/tree/master/036