Created
January 30, 2017 21:17
-
-
Save patrickfav/e6d6eb63fc0bea30f87b94d3e7b29c9c to your computer and use it in GitHub Desktop.
Example for how to reproduce the restart bug in Seismic
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<manifest package="com.company.seismicbug" | |
xmlns:android="http://schemas.android.com/apk/res/android"> | |
<application | |
android:allowBackup="true" | |
android:icon="@mipmap/ic_launcher" | |
android:label="@string/app_name" | |
android:roundIcon="@mipmap/ic_launcher_round" | |
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=".HearShakeActivity"/> | |
</application> | |
</manifest> |
This file contains 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
import android.content.Context; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.support.v7.app.AppCompatActivity; | |
import android.util.Log; | |
public class HearShakeActivity extends AppCompatActivity { | |
private static final String TAG = HearShakeActivity.class.getName(); | |
public static void start(Context context) { | |
Intent starter = new Intent(context, HearShakeActivity.class); | |
context.startActivity(starter); | |
} | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
Log.d(TAG, "onCreate"); | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_shake); | |
} | |
@Override | |
public void onBackPressed() { | |
super.onBackPressed(); | |
Log.d(TAG, "onBackPressed"); | |
} | |
@Override | |
protected void onDestroy() { | |
super.onDestroy(); | |
Log.d(TAG, "onDestroy"); | |
} | |
} |
This file contains 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
import android.hardware.SensorManager; | |
import android.os.Bundle; | |
import android.support.v7.app.AppCompatActivity; | |
import android.util.Log; | |
import com.squareup.seismic.ShakeDetector; | |
public class MainActivity extends AppCompatActivity { | |
private static final String TAG = MainActivity.class.getName(); | |
private ShakeDetector shakeDetector; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
Log.d(TAG, "onCreate"); | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
shakeDetector = new ShakeDetector(new ShakeDetector.Listener() { | |
@Override | |
public void hearShake() { | |
Log.d(TAG,"hear shake"); | |
HearShakeActivity.start(MainActivity.this); | |
} | |
}); | |
} | |
@Override | |
protected void onResume() { | |
super.onResume(); | |
Log.d(TAG,"onResume"); | |
shakeDetector.start((SensorManager) getSystemService(SENSOR_SERVICE)); | |
} | |
@Override | |
protected void onPause() { | |
super.onPause(); | |
Log.d(TAG,"onPause"); | |
shakeDetector.stop(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment