diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 index fb20b581509887918d9ba3a24cc15d0381bb7475..1354dbf76a92f9835fed9a1589b2d21487ea307c 100644 --- a/entry/build-profile.json5 +++ b/entry/build-profile.json5 @@ -10,7 +10,7 @@ "ruleOptions": { "enable": false, "files": [ - "./obfuscation-rules.txt" +// "./obfuscation-rules.txt" ] } } diff --git a/myhar/src/official_pages/OfficialSecondPage.ets b/myhar/src/official_pages/OfficialSecondPage.ets index c5b9e430a6fa76448ddb7d1cc52561cfbc732971..96cfab05c0b7f5394511e6dd665573211b94cc21 100644 --- a/myhar/src/official_pages/OfficialSecondPage.ets +++ b/myhar/src/official_pages/OfficialSecondPage.ets @@ -12,10 +12,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { PromptAction } from '@kit.ArkUI'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BusinessError } from '@kit.BasicServicesKit' import libAdd from 'libAdd.so'; import libSub from 'libSub.so'; import { ParamTextInputComponent } from '../main/ets/view/ParamTextInputComponent'; -import { promptAction } from '@kit.ArkUI'; @Component export struct OfficialSecond { @@ -30,7 +32,12 @@ export struct OfficialSecond { } customToast(str: ResourceStr) { + try { + let promptAction: PromptAction = this.getUIContext().getPromptAction(); promptAction.showToast({ message: str, duration: 2000, bottom: '80vp' }) + } catch (error) { + let err = error as BusinessError; + hilog.error(0x0000, 'testTag', `showToast fail. code = ${err.code}, message = ${err.message}`); } } build() { diff --git a/myhar/src/test_pages/TestSecondPage.ets b/myhar/src/test_pages/TestSecondPage.ets index f6d492bed7a11cf44585713ae87a02806474c2fa..4632701e78b22c7bb879dfec759a6897c7b3cd85 100644 --- a/myhar/src/test_pages/TestSecondPage.ets +++ b/myhar/src/test_pages/TestSecondPage.ets @@ -12,9 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { PromptAction } from '@kit.ArkUI'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BusinessError } from '@kit.BasicServicesKit' import libSub from 'libSub.so'; import { ParamTextInputComponent } from '../main/ets/view/ParamTextInputComponent'; -import { promptAction } from '@kit.ArkUI'; @CustomDialog struct CustomDialogExample { @@ -44,7 +46,13 @@ export struct TestSecond { } customToast(str: ResourceStr) { - promptAction.showToast({ message: str, duration: 2000, bottom: '80vp' }) + try { + let promptAction: PromptAction = this.getUIContext().getPromptAction(); + promptAction.showToast({ message: str, duration: 2000, bottom: '80vp' }) + } catch (error) { + let err = error as BusinessError; + hilog.error(0x0000, 'testTag', `showToast fail. code = ${err.code}, message = ${err.message}`); + } } build() {