[android-developers] Issue with WindowManager showing UI
Hi,
I have just created this small application which shows simple textview
on receiving incoming call. This app works perfectly on emulator.
Also it works very well when I launch main activity of application and
I receive incoming call.
But now if I restart phone and if I receive incoming call, the
TextView UI won't show up. If I check debug log everything seems
working fine i.e. my broadcast receiver receives event and invokes
function to show UI. But actual UI never shows up.
Now if I again launch application main activity and receive incoming
call, UI shows up properly.
Below is the code snippet:
---------------------------------------------------------------------------------------------------------------------------------------------------
public class IncomingCallReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent arg1) {
TelephonyManager telephony = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
int callState = telephony.getCallState();
switch (callState) {
case TelephonyManager.CALL_STATE_IDLE: {
Log.d(MainActivity.TAG, "CALL_STATE_IDLE");
hideUI(context) ;
}
break;
case TelephonyManager.CALL_STATE_OFFHOOK: {
Log.d(MainActivity.TAG, "CALL_STATE_OFFHOOK");
hideUI(context) ;
}
break;
case TelephonyManager.CALL_STATE_RINGING: {
Log.d(MainActivity.TAG, "CALL_STATE_RINGING");
showUI(context) ;
}
break;
}
}
private WindowManager mWindowManager;
static View mainView ;
private void showUI(Context context) {
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("This is text view do you see it ?");
mainView = view;
mWindowManager.addView(view, lp);
Log.d(MainActivity.TAG, " showUI done");
}
}
----------------------------------------------------------------------------------------------------------------------------------------------------------
Not sure what could be the cause of behavior . Any clues ?
--Tushar
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home