I have make an app that can show missed call when screen is locked,but I don't know how to show number of missed call on the locked screen.the call image is from MultiWaveView
which has defined already,I have trid using OnDraw
,with Canvas
and paint
,draw the specify coordinate.but it doesn't work .so anyone help me?thanks a lot.
how to show the number(e.g.in picture is position 2 )in the picutre?
edit1
for now I have get the right number of missed call in app,but it doesn't show correctly
class:
framework\base\core\java\com\android\internal\widget\multiwaveview\MissedCallView.java
public class MissedCallView extends View {
private static final String TAG = "MissedCallViews";
public static final int UPDATESTART = 10;
private static final int DELAYTIME = 10000;
private int sTempMissedCallCount=-1;
Context mContext;
Canvas mCanvas;
public MissedCallView(Context context)
{
super(context);
Log.i(TAG, "MissedCallView1");
mCanvas=new Canvas();
}
public MissedCallView(Context context, AttributeSet attrs)
{
super(context, attrs);
Log.i(TAG, "MissedCallView2");
mCanvas=new Canvas();
}
public MissedCallView(Context context,int missedCallNum) {
super(context);
sTempMissedCallCount=missedCallNum;
Log.i(TAG, "MissedCallView3");
mCanvas=new Canvas();
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if(sTempMissedCallCount>0)
{
Paint paint=new Paint(Paint.ANTIALIASFLAG);
paint.setColor(Color.RED); Log.i(TAG,"Integer.toString(sTempMissedCallCount)is:"+Integer.toString(sTempMissedCallCount)); canvas.drawText(Integer.toString(sTempMissedCallCount),40,310,paint);//50 invalidate();
Log.i(TAG, "invalidate");
}
}
}
this is the custom view ,Only MissedCallView(Context context,int missedCallNum)
works ,it called at public class MissCallObserver extends ContentObserver
when listen the missed called number .but the onDraw doesn't work ,so the app doesn't show the number I have got.
EDIT2:
for now I call the function in my custom hanlder, handler do every 10 second
private final Handler mUpdateMissCallNum = new Handler() {
@Override
public void handleMessage(Message msg) {
Log.i(TAG, "mUpdateMissCallNum");
switch (msg.what) {
case UPDATESTART:
Log.i(TAG, "UPDATESTART");
sNewMissedCallCount = getMissedCallCount(mContext);
if (sNewMissedCallCount != sTempMissedCallCount)
{
Log.i(TAG, "sNewMissedCallCount != sTempMissedCallCount");
new Thread(new Runnable()
{
public void run()
{
Log.i(TAG, "sNewMissedCallCount is:"+sNewMissedCallCount);
Log.i(TAG, "sTempMissedCallCount is:"+sTempMissedCallCount);
sTempMissedCallCount = sNewMissedCallCount;
mMissedCallView=new MissedCallView(mContext,sTempMissedCallCount);
//call my costum view here
Log.i(TAG, "sTempMissedCallCount is:"+sTempMissedCallCount);
}
}
).start();
}
break;
default:
break;
}
}
}
I draw it with canvas and paint,without XML files
then I lock screen in XML:Keyguardscreentabunlock.xml (framework\base\core\res\res\layout).
which is use Ripple Lock in system:
<com.android.internal.widget.multiwaveview.MultiWaveView
android:id="@+id/unlockwidget"
android:orientation="horizontal"
android:layoutwidth="matchparent"
android:layoutheight="matchparent"
android:layout_alignParentBottom="true"
android:targetDrawables="@array/lockscreen_targets_with_camera"
android:targetDescriptions="@array/lockscreen_target_descriptions_with_camera"
android:directionDescriptions="@array/lockscreen_direction_descriptions"
android:handleDrawable="@drawable/ic_lockscreen_handle"
android:waveDrawable="@drawable/ic_lockscreen_outerring"
android:outerRadius="@dimen/multiwaveview_target_placement_radius"
android:snapMargin="@dimen/multiwaveview_snap_margin"
android:hitRadius="@dimen/multiwaveview_hit_radius"
android:rightChevronDrawable="@drawable/ic_lockscreen_chevron_right"
android:horizontalOffset="0dip"
android:verticalOffset="60dip"
android:feedbackCount="3"
android:vibrationDuration="20"
/>
then I get this :
Now I want to show the missed call number on the center of the circle(in the picuture mouse position.),And I don't know how to achieve.