I've made a simple app that needs (yes it really does) to show an immersive warning. I've implemented this with an activity launched from a service. Most of the time it shows correctly, but sometime when the wearable is idle it doesn't. onStart() and onResume() runs but the view doesn't show on screen. Any ideas ?
(This is on an Android Gear Live from I/O)
It's triggered from a service by :
Intent i = new Intent(MyService.this, MyActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.setAction("disconnected");
startActivity(i);
Some of the activities code:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d("MyActivity", "onCreate");
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON|
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON|
WindowManager.LayoutParams.FLAG_FULLSCREEN |
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD|
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
setContentView(R.layout.activity);
disconnectedView = (TextView)findViewById(R.id.disconnectedView);
}
@Override
protected void onStart() {
super.onStart();
Log.d("MyActivity", "onStart");
}
@Override
protected void onResume() {
// Corrected after comment from MikeC
//super.onStart();
super.onResume();
Log.d("MyActivity", "onResume");
if (getIntent().getAction() != null && getIntent().getAction().equals("disconnected"))
startVibration();
}
Try setting the flags in onResume()
instead, seems to have worked for me.
@Override
public void onResume()
{
super.onResume();
// Keep awake
getWindow().addFlags( WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON );
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With