真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

第三方鎖屏應(yīng)用開發(fā)-創(chuàng)新互聯(lián)

要開發(fā)一個(gè)解鎖應(yīng)用有兩個(gè)途徑,一個(gè)是直接修改framework,按系統(tǒng)解鎖一樣直接在framework層實(shí)現(xiàn),另外的方法就是直接開發(fā)一個(gè)第三方鎖屏的應(yīng)用,在power off時(shí)啟動這個(gè)應(yīng)用,?poweron時(shí)首先出現(xiàn)的是這個(gè)應(yīng)用,只有解鎖關(guān)閉這個(gè)應(yīng)用時(shí)才會進(jìn)入系統(tǒng)界面。

專業(yè)從事網(wǎng)站設(shè)計(jì)制作、成都做網(wǎng)站,高端網(wǎng)站制作設(shè)計(jì),微信小程序,網(wǎng)站推廣的成都做網(wǎng)站的公司。優(yōu)秀技術(shù)團(tuán)隊(duì)竭力真誠服務(wù),采用html5+CSS3前端渲染技術(shù),響應(yīng)式網(wǎng)站建設(shè),讓網(wǎng)站在手機(jī)、平板、PC、微信下都能呈現(xiàn)。建站過程建立專項(xiàng)小組,與您實(shí)時(shí)在線互動,隨時(shí)提供解決方案,暢聊想法和感受。

開發(fā)這樣一個(gè)的鎖屏應(yīng)用,?可以分為如下幾個(gè)方面,

1)上鎖 2)鎖屏界面 3)解鎖

1,上鎖

上鎖要完成的事情是在power off時(shí)啟動鎖屏界面的activity,所以開啟一個(gè)service只要監(jiān)聽android.intent.action.SCREEN_OFF這個(gè)消息即可,這個(gè)service一直運(yùn)行,不會隨著鎖屏activity的結(jié)束而解鎖。當(dāng)啟動了自定義的activity時(shí),實(shí)際上系統(tǒng)的解鎖還是存在的,所以還要調(diào)用系統(tǒng)的disableKeyguard把系統(tǒng)的解鎖停掉。

private BroadcastReceiver mScreenMonitor = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
    //Utility.log("onReceive ??" );????????????????????????
    String action = intent.getAction();
?   ...????????????????

    if (android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED.equals(intent.getAction()))
????{
?????//在設(shè)置里更改系統(tǒng)解鎖是要重新disable
?????   AntiKeyguard.getInstance(context).reenable(false); 
        AntiKeyguard.getInstance(context).disable(false);????????????????????????????????
?????   return;
????}
????else if (action.equals(Intent.ACTION_SCREEN_OFF)){
??????????startLockActivityWhenScreenOff(context);
????}
    }
};



private void startLockActivityWhenScreenOff(Context context)
{
    TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    int call_state = tm.getCallState();
    if (TelephonyManager.CALL_STATE_IDLE != call_state) {//通話狀態(tài)時(shí)
        return;
}

Intent i = new Intent(context, LockerActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);//長按home鍵時(shí)不顯示圖標(biāo)
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pi = PendingIntent.getActivity(context, 0, i, 0);

try {
    pi.send();
} catch (PendingIntent.CanceledException ex) {

}

//允許第三方解鎖繼續(xù)接受
//abortBroadcast(); ????????????????????????
//play sound when lock
Water.soundPlayLock();

}

要注意的地方是android.intent.action.SCREEN_OFF不能在AndroidManifest.xml中注冊,要動態(tài)注冊。

public void onCreate() {
    super.onCreate();
?   IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_SCREEN_OFF);//注冊SCREEN_OFF事件
?   filter.addAction("android.app.action.DEVICE_POLICY_MANAGER_STATE_CHANGED");

    //優(yōu)先級設(shè)到最高
    filter.setPriority(2147483647);
    registerReceiver(mScreenMonitor, filter);//注冊廣播
    AntiKeyguard.getInstance(this).disable(false);//disable系統(tǒng)鎖屏
}

2, 鎖屏界面

鎖屏界面可以分為兩部分內(nèi)容:

1)基本信息的顯示,如時(shí)間,日期,電池狀態(tài),未接電話,未接來電等等信息,這部分基本是所有解鎖通用的。為了顯示這些信息,我們需要注冊一些receiver來處理

//時(shí)間,電量

private BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
    // Util.log("onReceive_activity");
    String action = intent.getAction();
    if (Intent.ACTION_TIME_TICK.equals(action)) {
         long millis = System.currentTimeMillis();
         showTime(millis);
         showDate(millis);
    } else if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
        if (0 != intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0)) {
            int state = intent.getIntExtra(BatteryManager.EXTRA_STATUS,BatteryManager.BATTERY_STATUS_UNKNOWN);
            int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL,0);
            int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE,0);
            int plugFlag = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0);
            showCharge(state, level, scale, plugFlag);
        } else {
            hideCharge();
        }
    }

}
};

//短信

private class MsgObserver extends ContentObserver {

public MsgObserver(Handler handler) {
    super(handler);
    // Util.log("MsgObserver");
}

@Override
public void onChange(boolean selfChange) {
    // Log.d("Test", "MsgObserver onChange");
    showMissedMsg();
}

}

//未接來電

private class CallObserver extends ContentObserver {

public CallObserver(Handler handler) {
    super(handler);
    // Util.log("CallObserver");
}

@Override
public void onChange(boolean selfChange) {
    // Log.d("Test", "CallObserver onChange");
    showMissedCall();
}

}

2)與解鎖操作相關(guān)的ui顯示,如一些圖標(biāo),一些動畫特效等等,這個(gè)每個(gè)解鎖都會不一樣

3,解鎖后的處理

當(dāng)解鎖操作符合指定的條件時(shí),如滑動了一定的長度,拖動到指定的icon上,這時(shí)就表示解鎖完成,要離開解鎖界面進(jìn)入指定的應(yīng)用或laucher,這部分基本所有的解鎖也是一樣的

public void onTrigger(View v, int target) {
?   Intent intent = null;
    switch (target) {
        case 0:
            break;
        case 1:
            intent = new Intent(Intent.ACTION_DIAL);
            break;
        case 2:
            intent = new Intent(Intent.ACTION_MAIN);
            intent.setType("vnd.android-dir/mms-sms");
            break;
        case 3:
            intent = new Intent();
            intent.setComponent(new ComponentName("com.android.browser",?"com.android.browser.BrowserActivity"));
            break;
        case 4:
            intent = new Intent();
            intent.setAction("android.media.action.STILL_IMAGE_CAMERA");
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
            break;
        case 5:
            intent = new Intent(Intent.ACTION_VIEW);
            intent.setType("vnd.android.cursor.dir/calls");
            break;
        case 6:
            intent = new Intent(Intent.ACTION_MAIN);
            intent.setType("vnd.android-dir/mms-sms");
            break;
        default:
            break;
    }

    if (intent != null)
        startActivity(intent);
    finishMyself();
    overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
?}

4,常見問題

1)解鎖完成時(shí)黑屏問題

public void onAttachedToWindow() {
    // getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);//導(dǎo)致解鎖時(shí)屏幕變黑
    getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
}

android:theme="@android:style/Theme.Translucent.NoTitleBar"


2)側(cè)鍵不能調(diào)節(jié)音量

在播放音樂時(shí),不要屏蔽音量調(diào)節(jié)鍵

AudioManager manager = (AudioManager) 
this.getSystemService(Context.AUDIO_SERVICE);????????????????
if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP)
&& manager.isMusicActive()) {
    return super.onKeyDown(keyCode, event);
}

3)來電或鬧鐘處理

public class PhoneReceiver extends BroadcastReceiver {

    private LockPatternUtils lockPatternUtils = null;
    public void onReceive(Context context, Intent intent) {
         if(intent.getAction().equals("android.intent.action.PHONE_STATE")) {
             TelephonyManager tm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
             int call_state = tm.getCallState();
             if (TelephonyManager.CALL_STATE_IDLE != call_state) {
                 if (Utility.COMPAT_SYSTEM_LOCK)
                 {
                     if (lockPatternUtils == null) {
                         lockPatternUtils = new LockPatternUtils(context);
                     }
                     if (!lockPatternUtils.isSecureDual()) {
                         pause(context);????????????????????????????????????????
                     }
                 }
                 else
                     pause(context);
                 }
             else {
                 if (Utility.COMPAT_SYSTEM_LOCK)
                 {
                     if (lockPatternUtils == null) {
                         lockPatternUtils = new LockPatternUtils(context);
                     }
                     if (!lockPatternUtils.isSecureDual()) {
                         resume(context);
                     }
                 }
                 else
                     resume(context);
                 }
             }
         else ?{
             if(intent.getAction().equals("com.android.deskclock.ALARM_ALERT")) {
                 Utility.log("ALARM_ALERT");
                 pause(context);
             }
             else if(intent.getAction().equals("com.android.deskclock.ALARM_DONE")) {
                 Utility.log("ALARM_killed");
                 resume(context);
             }
             else if(intent.getAction().equals("com.android.deskclock.ALARM_SNOOZE")) {
                 Utility.log("ALARM_cancel_snooze");
                 resume(context);
             }
         }
     }

private void pause(Context context) {
    LockerActivity activity = LockerActivity.getInstance();
    if(activity != null) {
        activity.finishMyself();
        LockerActivity.setStateStopTemp();
    }
}

private void resume(Context context) {
    if(!LockerActivity.getState()) {
        return;
    }
    Intent i = new Intent(context, LockerActivity.class);
    i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);//長按home鍵時(shí)不顯示圖標(biāo)
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent pi = PendingIntent.getActivity(context, 0, i, 0);
    try {
        pi.send();
    } catch (PendingIntent.CanceledException ex) {
}

LockerActivity.resetState();
}

}

4,?home鍵時(shí)不顯示圖標(biāo)

i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);//長按home鍵時(shí)不顯示圖標(biāo)

5,系統(tǒng)解鎖屏蔽

.????在鎖屏server ?oncreate時(shí)調(diào)用一次

AntiKeyguard.getInstance(this).disable(false);

?在解鎖完成后,鎖屏activity的

protected void onDestroy() {
    if (!Utility.COMPAT_SYSTEM_LOCK) {
        AntiKeyguard.getInstance(this).reenable(false);
        if (mBVerifiedBinding)
            AntiKeyguard.getInstance(this).disable(false);????????
    }
}

在鎖屏server ?onDestroy時(shí)調(diào)用一次

AntiKeyguard.getInstance(this).reenable(false);

6,?系統(tǒng)設(shè)置里改動鎖屏類型時(shí)重新打開系統(tǒng)鎖屏

處理filter.addAction("android.app.action.DEVICE_POLICY_MANAGER_STATE_CHANGED");

if (android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED.equals(intent.getAction()))
{
?   AntiKeyguard.getInstance(context).reenable(false);
?   AntiKeyguard.getInstance(context).disable(false);????????????????????????????????
??  return;
}

你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級服務(wù)器適合批量采購,新人活動首月15元起,快前往官網(wǎng)查看詳情吧


文章標(biāo)題:第三方鎖屏應(yīng)用開發(fā)-創(chuàng)新互聯(lián)
網(wǎng)站URL:http://weahome.cn/article/djjgei.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部