目前分類:功能 (37)

瀏覽方式: 標題列表 簡短摘要

如何在function內執行

1.Runnable:不傳參數

JBLin 發表在 痞客邦 留言(0) 人氣()

五秒內執行startForeground否則出現ANR錯誤

caller

JBLin 發表在 痞客邦 留言(0) 人氣()

1.權限宣告(be called AndroidManifest.xml)

<permission android:name="package.permissionDeclare" android:protectionLevel="signature"></permission> //protectionLevel 管制permission等級

Activity、service、receiver、Provider都可以使用

JBLin 發表在 痞客邦 留言(0) 人氣()

val listType: Type = object : TypeToken<ArrayList<JavaBean?>?>() {}.type
var JavaBeanList : List<JavaBean> = Gson().fromJson(it, listType)

JBLin 發表在 痞客邦 留言(0) 人氣()

IListener.aidl(callback)

interface IListener {
    void callback(String callbackString);
}

IManager.aidl(server)

JBLin 發表在 痞客邦 留言(0) 人氣()

1.create TestDeviceAdminReceiver class

public class TestDeviceAdminReceiver extends DeviceAdminReceiver {
    @Override
    public void onEnabled(final Context context, Intent intent) {
        super.onEnabled(context, intent);
        Log.d("test", "Device Owner Enabled");
    }
    
    @Override
    public void onDisabled(Context context, Intent intent) {
        super.onDisabled(context, intent);
    }
}

2.create device_admin.xml

JBLin 發表在 痞客邦 留言(0) 人氣()

packageManager.getPackageInfo(packageName,0).applicationInfo.dataDir

JBLin 發表在 痞客邦 留言(0) 人氣()

1.AndroidManifest.xml宣告系統權限

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="" android:sharedUserId="android.uid.system">

2.AndroidManifest.xml宣告系統應用程式

JBLin 發表在 痞客邦 留言(0) 人氣()

1.AndroidManifest.xml 宣告對外service

<service android:name=".UserControlService">
    <intent-filter>
        <action android:name="1"></action>
    </intent-filter>
</service>

2.service server AIDL (實作AIDL interface給client端使用)

JBLin 發表在 痞客邦 留言(0) 人氣()

pid: 

android.os.Process.myPid()

uid:

JBLin 發表在 痞客邦 留言(0) 人氣()

1.需要以下權限
INTERACT_ACROSS_USERS (signature|system)

JBLin 發表在 痞客邦 留言(0) 人氣()

新增:adb shell pm create-user userName
移除:adb shell pm remove-user UserID

JBLin 發表在 痞客邦 留言(0) 人氣()

git  https://github.com/JeremyLiao/LiveEventBus

JBLin 發表在 痞客邦 留言(0) 人氣()

1.啟動原生google search voice來取得辨識文字

自定義回傳code

JBLin 發表在 痞客邦 留言(0) 人氣()

 

Activity處理危險權限

//請求權限

JBLin 發表在 痞客邦 留言(0) 人氣()

private final static int REQUEST_CONTACTS = 1;//自定義回傳數值
@Override
protected void onCreate(Bundle savedInstanceState) {
int permission = ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_CALENDAR);//權限確認
if(permission != PackageManager.PERMISSION_GRANTED){//沒有獲得全縣
    ActivityCompat.requestPermissions( this,
            new String[]{Manifest.permission.READ_CALENDAR}, REQUEST_CONTACTS );//要求權限
}

}

 

JBLin 發表在 痞客邦 留言(0) 人氣()

androidManifest.xml 宣告provider

<provider
    android:authorities="testContentProvider" //content://testContentProvider
    android:name=".content"> //class名稱
</provider>


文章標籤

JBLin 發表在 痞客邦 留言(0) 人氣()

activity
textview.setSelected(true)

JBLin 發表在 痞客邦 留言(0) 人氣()

public class rec extends Service(Activity) implements RecognitionListener
private Intent recognizerIntent;
private SpeechRecognizer mSpeechRecognizer;

oncreat初始化

        recognizerIntent = new Intent();
        recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1);//指回傳一個結果
        mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(this, new ComponentName("com.google.android.googlequicksearchbox", "com.google.android.voicesearch.serviceapi.GoogleRecognitionService"));//指定使用ok google
        mSpeechRecognizer.setRecognitionListener(this);//連結RecognitionListener

啟動錄音

JBLin 發表在 痞客邦 留言(0) 人氣()

START_STICKY:如果service进程被kill掉,保留service的状态为开始状态,但不保留递送的intent对象。随后系统会尝试重新创建service,由于服务状态为开始状态,所以创建服务后一定会调用onStartCommand(Intent,int,int)方法。如果在此期间没有任何启动命令被传递到service,那么参数Intent将为null。
START_NOT_STICKY:“非粘性的”。使用这个返回值时,如果在执行完onStartCommand后,服务被异常kill掉,系统不会自动重启该服务。
START_REDELIVER_INTENT:重传Intent。使用这个返回值时,如果在执行完onStartCommand后,服务被异常kill掉,系统会自动重启该服务,并将Intent的值传入。
START_STICKY_COMPATIBILITY:START_STICKY的兼容版本,但不保证服务被kill后一定能重启。


JBLin 發表在 痞客邦 留言(0) 人氣()

1 2