Created
November 7, 2014 23:52
-
-
Save px-amaac/cbb318339ccbeefe038e to your computer and use it in GitHub Desktop.
App showing OS launching activity on the stack after crash.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:paddingLeft="@dimen/activity_horizontal_margin" | |
android:paddingRight="@dimen/activity_horizontal_margin" | |
android:paddingTop="@dimen/activity_vertical_margin" | |
android:paddingBottom="@dimen/activity_vertical_margin" | |
tools:context=".MyActivity"> | |
<TextView | |
android:text="@string/hello_world" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" /> | |
<Button | |
android:id="@+id/launch_main" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_centerInParent="true" | |
android:text="@string/launch_main"/> | |
<Button | |
android:id="@+id/launch_b" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_centerHorizontal="true" | |
android:text="@string/launch_b" | |
android:layout_below="@id/launch_main"/> | |
<Button | |
android:id="@+id/doit" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_centerHorizontal="true" | |
android:text="Do It" | |
android:layout_below="@id/launch_b"/> | |
</RelativeLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BActivity extends Activity implements View.OnClickListener { | |
private Button mLaunchMainButton; | |
private Button mLaunchBButton; | |
private Button mDoIt; | |
@Override protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
Log.e("bActivity", "otCreate"); | |
setContentView(R.layout.activity_my); | |
mLaunchMainButton = (Button) findViewById(R.id.launch_main); | |
mLaunchBButton = (Button) findViewById(R.id.launch_b); | |
mDoIt = (Button) findViewById(R.id.doit); | |
mLaunchMainButton.setOnClickListener(this); | |
mLaunchBButton.setOnClickListener(this); | |
mDoIt.setOnClickListener(this); | |
} | |
@Override protected void onResume() { | |
super.onResume(); | |
Log.e("bActivity", "onResume"); | |
} | |
public void doIt(View view) { | |
String[] strings = { "a", "b", "c" }; | |
for(int i = 0; i<= strings.length; i++) { | |
String x = strings[i]; | |
} | |
} | |
@Override public void onClick(View v) { | |
int viewId = v.getId(); | |
switch(viewId) { | |
case R.id.launch_main: | |
Intent mainIntent = new Intent(this, MyActivity.class); | |
startActivity(mainIntent); | |
break; | |
case R.id.launch_b: | |
Intent bIntent = new Intent(this, BActivity.class); | |
startActivity(bIntent); | |
break; | |
case R.id.doit: | |
doIt(v); | |
break; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyActivity extends Activity implements View.OnClickListener { | |
private Button mLaunchMainButton; | |
private Button mLaunchBButton; | |
private Button mDoIt; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
Log.e("bActivity", "otCreate"); | |
setContentView(R.layout.activity_my); | |
mLaunchMainButton = (Button) findViewById(R.id.launch_main); | |
mLaunchBButton = (Button) findViewById(R.id.launch_b); | |
mDoIt = (Button) findViewById(R.id.doit); | |
mLaunchMainButton.setOnClickListener(this); | |
mLaunchBButton.setOnClickListener(this); | |
mDoIt.setOnClickListener(this); | |
} | |
@Override protected void onResume() { | |
super.onResume(); | |
Log.e("bActivity", "onResume"); | |
} | |
@Override | |
public boolean onCreateOptionsMenu(Menu menu) { | |
// Inflate the menu; this adds items to the action bar if it is present. | |
getMenuInflater().inflate(R.menu.my, menu); | |
return true; | |
} | |
@Override | |
public boolean onOptionsItemSelected(MenuItem item) { | |
// Handle action bar item clicks here. The action bar will | |
// automatically handle clicks on the Home/Up button, so long | |
// as you specify a parent activity in AndroidManifest.xml. | |
int id = item.getItemId(); | |
if (id == R.id.action_settings) { | |
return true; | |
} | |
return super.onOptionsItemSelected(item); | |
} | |
public void doIt(View view) { | |
String[] strings = { "a", "b", "c" }; | |
for(int i = 0; i<= strings.length; i++) { | |
String x = strings[i]; | |
} | |
} | |
@Override public void onClick(View v) { | |
int viewId = v.getId(); | |
switch(viewId) { | |
case R.id.launch_main: | |
Intent mainIntent = new Intent(this, MyActivity.class); | |
startActivity(mainIntent); | |
break; | |
case R.id.launch_b: | |
Intent bIntent = new Intent(this, BActivity.class); | |
startActivity(bIntent); | |
break; | |
case R.id.doit: | |
doIt(v); | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment