From 3118f7a2b375a1147c01b4f7c6342a8c1d1c8cd3 Mon Sep 17 00:00:00 2001 From: "wang.weibin" Date: Wed, 14 Jul 2021 15:40:43 +0800 Subject: [PATCH] =?UTF-8?q?API=E5=AF=B9=E6=A0=87=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/ContextCompat.md | 23 +++++++++++++++++++++++ bundle/PackageManager.md | 9 +++++++++ data/SharedPreferences.md | 9 +++++++++ database/Cursor.md | 14 +++++++++++++- resource/Resources.md | 9 +++++++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 app/ContextCompat.md create mode 100644 bundle/PackageManager.md create mode 100644 data/SharedPreferences.md create mode 100644 resource/Resources.md diff --git a/app/ContextCompat.md b/app/ContextCompat.md new file mode 100644 index 0000000..ce83282 --- /dev/null +++ b/app/ContextCompat.md @@ -0,0 +1,23 @@ +### **checkSelfPermission(BeforeActivity.this, Manifest.permission.CALL_PHONE)** +>+ openharmony API: ohos.app.AbilityContext.verifySelfPermission +>+ openharmony SDK版本:2.1.1.18 +>+ IDE版本:2.1.0.301 +>+ 实现方案:替换使用,使用方法如下: +```java +AbilityContext context = new AbilityContext(); +int no = context.verifySelfPermission(SystemPermission.PLACE_CALL); +``` + + +### **requestPermissions(BeforeActivity.this, new String[]{Manifest.permission.CALL_PHONE})** +>+ openharmony API: ohos.app.AbilityContext.requestPermissionsFromUser +>+ openharmony SDK版本:2.1.1.18 +>+ IDE版本:2.1.0.301 +>+ 实现方案:替换使用,使用方法如下: +```java +private static final int PERMISSION_CODE_CALL = 100; + +AbilityContext context = new AbilityContext(); +context.requestPermissionsFromUser(new String[]{SystemPermission.PLACE_CALL}, PERMISSION_CODE_CALL); +}); +``` \ No newline at end of file diff --git a/bundle/PackageManager.md b/bundle/PackageManager.md new file mode 100644 index 0000000..4f85385 --- /dev/null +++ b/bundle/PackageManager.md @@ -0,0 +1,9 @@ +### **getPackageManager** +>+ openharmony API: ohos.bundle.IBundleManager.getBundleManager +>+ openharmony SDK版本:2.1.1.18 +>+ IDE版本:2.1.0.301 +>+ 实现方案:替换使用,使用方法如下: +```java +Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext(); +IBundleManager bundleManager = context.getBundleManager(); +``` diff --git a/data/SharedPreferences.md b/data/SharedPreferences.md new file mode 100644 index 0000000..fb429d5 --- /dev/null +++ b/data/SharedPreferences.md @@ -0,0 +1,9 @@ +### **edit** +>+ openharmony API: ohos.data.DatabaseHelper.getPreferences +>+ openharmony SDK版本:2.1.1.18 +>+ IDE版本:2.1.0.301 +>+ 实现方案:替换使用,使用方法如下: +```java +DatabaseHelper databaseHelper = new DatabaseHelper(context); +Preferences prefs = databaseHelper.getPreferences(PREF_NAME); +``` diff --git a/database/Cursor.md b/database/Cursor.md index b82d331..8a39b60 100644 --- a/database/Cursor.md +++ b/database/Cursor.md @@ -111,4 +111,16 @@ >+ openharmony API: `ohos.data.resultset.ResultSet` >+ openharmony SDK版本:2.1.0.17 >+ IDE版本:2.1.0.141 ->+ 实现方案:使用`close()`方法 \ No newline at end of file +>+ 实现方案:使用`close()`方法 + +### **query(uri, projection, selection, selectionArgs, sortOrder)** +>+ openharmony API: `ohos.data.resultset.ResultSet` +>+ openharmony SDK版本:2.1.1.18 +>+ IDE版本:2.1.0.302 +>+ 实现方案:使用`query(uri, columns, predicates)`方法 + +### **getColumnIndex(columnName)** +>+ openharmony API: ohos.data.resultset.ResultSet.getColumnIndexForName +>+ openharmony SDK版本:2.1.1.18 +>+ IDE版本:2.1.0.302 +>+ 实现方案:使用`getColumnIndexForName(columns)`方法 \ No newline at end of file diff --git a/resource/Resources.md b/resource/Resources.md new file mode 100644 index 0000000..3c110a6 --- /dev/null +++ b/resource/Resources.md @@ -0,0 +1,9 @@ +### **openRawResource** +>+ openharmony API: hos.global.resource.ResourceManager.getRawFileEntry +>+ openharmony SDK版本:2.1.1.18 +>+ IDE版本:2.1.0.301 +>+ 实现方案:替换使用,使用方法如下: +```java +RawFileEntry rawFileEntry = context.getResourceManager().getRawFileEntry("resources/rawfile/code/" + mdFileName); +MarkDown.fromMarkdown(rawFileEntry.openRawFile()); +``` -- Gitee