我的应用程序在某些版本和某些建议中不起作用。
例如:
- 三星 4.04 -作品
- 摩托罗拉 4.04 -坏了
- 三星 2.3.6 -作品
- LG 2.2.2 -坏了
如果有人知道发生了什么,请告诉我。我觉得这一定很简单。
我的清单声明 min sdk=4 和 max=16。
我使用 ViewFlipper 来更改布局,也许这就是问题所在。该应用程序仅在到达此部分时关闭。
很抱歉没有崩溃日志。
public class ImagesActivity extends Activity {
private SensorManager mSensorManager;
private ShakeEventListener mSensorListener;
private ViewFlipper mFlipper;
private Animation Animation, Animation2, Animation3, Animation4;
private Random randomGenerator = new Random();
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.imagesview);
final LinearLayout myLayout = (LinearLayout) findViewById(R.id.images_view);
//declaração ViewFlipper das telas
mFlipper = (ViewFlipper) findViewById(R.id.mFlipper1);
//declaração das var para o evento Shake
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mSensorListener = new ShakeEventListener();
//declaração anim 1 - Slide from left
Animation = (Animation) AnimationUtils.loadAnimation(this, R.anim.slideleft);
Animation.setFillAfter(true);
//declaração anim 2 - Slide from right
Animation2 = (Animation) AnimationUtils.loadAnimation(this, R.anim.slideright);
Animation.setFillAfter(true);
//declaração anim 3 - Slide from down
Animation3 = (Animation) AnimationUtils.loadAnimation(this, R.anim.slideup);
Animation.setFillAfter(true);
//declaração anim 4 - Slide from up
Animation4 = (Animation) AnimationUtils.loadAnimation(this, R.anim.slidedown);
Animation.setFillAfter(true);
//Event Shake para execução das telas random
mSensorListener.setOnShakeListener(new ShakeEventListener.OnShakeListener() {
public void onShake() {
int random;
Random RandomView = new Random();
int nextViewIndex = RandomView.nextInt(18);
while (nextViewIndex == mFlipper.getDisplayedChild()) {
nextViewIndex = RandomView.nextInt(18);
}
random = randomGenerator.nextInt(4);
if(random ==1)
myLayout.startAnimation(Animation);
else if(random ==2)
myLayout.startAnimation(Animation2);
else if(random ==3)
myLayout.startAnimation(Animation3);
else
myLayout.startAnimation(Animation4);
mFlipper.setDisplayedChild(nextViewIndex);
}
});
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onResume() {
super.onResume();
mSensorManager.registerListener(mSensorListener,
mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
SensorManager.SENSOR_DELAY_UI);
}
@Override
public void onPause() {
mSensorManager.unregisterListener(mSensorListener);
super.onStop();
}
}