Note that there are some explanatory texts on larger screens.

plurals
  1. POWindowManager is unable to show Window View on screen even though it's visibility property is true
    primarykey
    data
    text
    <p>My application shows UI based on events received in various BroacastReceiver . Since I need to generate view directly from BroadcastReceiver I use code like this :</p> <pre><code>mWindowManager = (WindowManager) context .getSystemService(Context.WINDOW_SERVICE); WindowManager.LayoutParams lp = new WindowManager.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_TOAST, WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.OPAQUE); TextView view = new TextView(context); view.setText("You got Broadcast !"); mainView = view; mWindowManager.addView(view, lp); Log.d("MyApp"," View shown ") </code></pre> <p>This code displays TextView with text "You got Broadcast" properly when I receive BroadcastReceiver event when my main application activity is accessed beforehand. Means if my application is in memory and my main activity has been shown. </p> <p>Now when I restart phone and my BroadcastReceiver receives event everything works fine. Infact I can see the debug statement "MyApp, View shown" in logcat. But strangely, actual view with text "You got Broadcast" does not appear on screen. Now again I launch my main activity and press home button . Now if BroadcastReceiver again receives event, it is now able to show the texview with text "You got Broadcast" properly.</p> <p>At present I'm not doing anything in main activity apart from showing default generated xml layout. It's dead simple code :</p> <pre><code>public class MainActivity extends Activity { public static final String TAG = "MainActivity"; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Log.d(TAG, " Main screen"); } </code></pre> <p>}</p> <p>Am I missing some screen/graphics initialization which happens when main activity is launched ? Or do I need to pass on any additional parameter to WindowManager ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload