gpt4 book ai didi

android - 如何有意地在 whatsapp 中打开与特定号码的对话

转载 作者:行者123 更新时间:2023-11-29 23:28:26 26 4
gpt4 key购买 nike

我正在尝试使用 intents 在 whatsapp 中打开与电话号码的对话,我当前的代码运行良好,但突然停止工作,当我调用该函数时,它尝试打开 Whatsapp 但没有成功,并且在 logcat 中有没有错误信息,我当前的代码是

private void accion_abrir_whatsapp(String num_telefono) {
boolean is_whatsapp_installed = appInstalledOrNot("com.whatsapp");
if(is_whatsapp_installed) {
Uri uri = Uri.parse("smsto:" + num_telefono);
Intent i = new Intent(Intent.ACTION_SENDTO, uri);
i.setPackage("com.whatsapp");
startActivity(Intent.createChooser(i, ""));
}else{
toast("No tienes instalado Whatsapp para esta accion");
}

}

在 logcat 中,我用 whatsapp 这个词过滤了所有消息并得到了这个。

2018-11-02 22:46:54.783 1052-2355/? D/ActivityManager: Skipping intent:flg=0x10800000 cmp=com.whatsapp/.voipcalling.VoipActivityV2
2018-11-02 22:46:54.868 1052-1200/? W/AlarmManager: mIsScreenOn is: true, WAKEUP alarm trigger action = com.whatsapp.alarm.AVAILABLE_TIMEOUT package name is: com.whatsapp
2018-11-02 22:46:54.873 1052-2355/? V/BroadcastQueue: Finished with ordered broadcast BroadcastRecord{5cab0ac u10 com.whatsapp.alarm.AVAILABLE_TIMEOUT}
2018-11-02 22:46:55.791 1052-2355/? I/ActivityManager: START u0 {act=android.intent.action.SENDTO dat=smsto:xxxxxxxxxxxxxxxxxx flg=0x3000000 hwFlg=0x2 pkg=com.whatsapp cmp=com.whatsapp/.Conversation} from uid 10232
2018-11-02 22:46:55.792 1052-2355/? I/ActivityManager: ActivityRecord info: ActivityInfo{88994f1 com.whatsapp.Conversation}
2018-11-02 22:46:55.794 1052-2355/? V/WindowManager: addAppToken: AppWindowToken{2882b98 token=Token{d0d617b ActivityRecord{71e050a u0 com.whatsapp/.Conversation t4923}}} controller={TaskWindowContainerController taskId=4923} at 2147483647
2018-11-02 22:46:55.795 1605-1986/? I/ash: front pkg : com.whatsapp launcher: false
2018-11-02 22:46:55.795 1605-1986/? I/ash: above launcher front pkgs: [io.app.malle, com.huawei.android.internal.app, com.whatsapp]
2018-11-02 22:46:55.850 1052-2355/? V/WindowManager: No longer Stopped: AppWindowToken{2882b98 token=Token{d0d617b ActivityRecord{71e050a u0 com.whatsapp/.Conversation t4923}}}
2018-11-02 22:46:55.859 8166-8166/? V/ActivityThread: Skipping new config:{1.0 714mcc3mnc [es_AR] ldltr sw360dp w360dp h677dp 480dpi nrml long hdr port finger -keyb/v/h -nav/h appBounds=Rect(0, 0 - 1080, 2116) nonFullScreen=0 suim:1 s.246}, config:{1.0 714mcc3mnc [es_AR] ldltr sw360dp w360dp h677dp 480dpi nrml long hdr port finger -keyb/v/h -nav/h appBounds=Rect(0, 0 - 1080, 2116) nonFullScreen=0 suim:1 s.246} for app:com.whatsapp
2018-11-02 22:46:55.859 1605-1710/? D/ScenarioService: front pkg : com.whatsapp launcher: false
2018-11-02 22:46:55.859 1605-1710/? D/ScenarioService: new above launcher front pkgs: [io.app.malle, com.huawei.android.internal.app, com.whatsapp]
2018-11-02 22:46:55.859 1605-1710/? I/AppManager: handleAppFrontEvent: com.whatsapp
2018-11-02 22:46:55.859 1605-1710/? I/AppsUsage: scnOff:false FgAPP:com.whatsapp BgAPP:com.huawei.android.internal.app
2018-11-02 22:46:55.859 1052-2355/? V/WindowManager: No longer Stopped: AppWindowToken{2882b98 token=Token{d0d617b ActivityRecord{71e050a u0 com.whatsapp/.Conversation t4923}}}
2018-11-02 22:46:55.860 1052-1282/? D/EmcomManagerService: forePackage name is com.whatsapp
2018-11-02 22:46:55.861 3135-7320/? D/[HwRecSys]HwRecSysService: onEvent actionID: 10000 msg:com.whatsapp
2018-11-02 22:46:55.861 1605-2112/? I/PGServer: report state:10000 event type:1 pid:0 uid:0 pkg:com.whatsapp to pid: 1052
2018-11-02 22:46:55.861 1605-2112/? I/PGServer: report state:10000 event type:1 pid:0 uid:0 pkg:com.whatsapp to pid: 1605
2018-11-02 22:46:55.861 1605-2112/? I/SceneReceiver: state type: 10000 eventType:1 pid:0 uid:0 pkg:com.whatsapp
2018-11-02 22:46:55.862 1605-2202/? D/HwThermalStateManager: current foreapp pkg : com.whatsapp
2018-11-02 22:46:55.862 1605-2202/? D/HwThermalStateManager: really app:com.whatsapp
2018-11-02 22:46:55.863 1052-2355/? V/WindowManager: Check opening app=AppWindowToken{2882b98 token=Token{d0d617b ActivityRecord{71e050a u0 com.whatsapp/.Conversation t4923}}}: allDrawn=false startingDisplayed=false startingMoved=false isRelaunching()=false
2018-11-02 22:46:55.876 1052-1073/? D/HiDATA_ContentAware: mForegroundAppPackageName: com.whatsapp ,score: 0
2018-11-02 22:46:55.876 1052-1073/? D/HiDATA: onForegroundAppWifiSleepChange: config:false, sleeptime:-1,type: 0, appname:com.whatsapp
2018-11-02 22:46:55.876 1052-1073/? D/HiDATA: APP type: 0 appName= com.whatsapp
2018-11-02 22:46:55.876 1052-1073/? D/HiDATA: no game, APP_TYPE_GAME, appName =com.whatsapp
2018-11-02 22:46:55.876 1052-1073/? D/HiDATA_ContentAware: packageName = com.whatsapp, uid = 10122
2018-11-02 22:46:55.886 8166-8166/? D/HwRTBlurUtils: check blur style for HwPhoneWindow, themeResId : 0x7f11015d, context : com.whatsapp.Conversation@ac8a57, Nhwext : 0, get Blur : disable with , null
2018-11-02 22:46:55.899 8166-8166/? D/ActivityThread: add activity client record, r= ActivityRecord{b6705b0 token=android.os.BinderProxy@b5b4175 {com.whatsapp/com.whatsapp.Conversation}} token= android.os.BinderProxy@b5b4175
2018-11-02 22:46:55.901 1052-2355/? D/ActivityManager: allPausedActivitiesComplete: r=ActivityRecord{71e050a u0 com.whatsapp/.Conversation t4923 f} state=FINISHING
2018-11-02 22:46:55.903 1605-1710/? I/ScenarioService: old above launcher pkgs: [io.app.malle, com.huawei.android.internal.app, com.whatsapp] new front:io.app.malle
2018-11-02 22:46:55.903 1605-1710/? I/AppsUsage: scnOff:false FgAPP:io.app.malle BgAPP:com.whatsapp
2018-11-02 22:46:55.906 1605-2112/? I/PGServer: report state:10000 event type:2 pid:0 uid:0 pkg:com.whatsapp to pid: 1052
2018-11-02 22:46:55.906 1605-2112/? I/PGServer: report state:10000 event type:2 pid:0 uid:0 pkg:com.whatsapp to pid: 1605
2018-11-02 22:46:55.906 1605-2112/? I/SceneReceiver: state type: 10000 eventType:2 pid:0 uid:0 pkg:com.whatsapp
2018-11-02 22:46:55.931 1052-2355/? D/WindowManager: is app exit to launcher info: app = AppWindowToken{cdc307c token=Token{1749b6f ActivityRecord{f5ede4e u0 com.huawei.android.internal.app/.HwChooserActivity t4923}}}, window = Window{d405503 u0 com.huawei.android.internal.app/com.huawei.android.internal.app.HwChooserActivity}mClosingApps = {AppWindowToken{2882b98 token=Token{d0d617b ActivityRecord{71e050a u0 com.whatsapp/.Conversation t4923}}}, AppWindowToken{cdc307c token=Token{1749b6f ActivityRecord{f5ede4e u0 com.huawei.android.internal.app/.HwChooserActivity t4923}}}}, topOpeningApp = AppWindowToken{ae4fe97 token=Token{ba3b516 ActivityRecord{c2f4a31 u0 io.app.malle/.Modulo_perfil_negocio t4923}}}, mExitIconBitmap = null, mExitIconHeight = -1, mExitIconWidth = -1
2018-11-02 22:46:56.021 1052-2355/? D/ActivityManager: Skipping intent:flg=0x10800000 cmp=com.whatsapp/.voipcalling.VoipActivityV2
2018-11-02 22:46:56.097 8166-8166/? D/ActivityThread: Remove activity client record, r= ActivityRecord{b6705b0 token=android.os.BinderProxy@b5b4175 {com.whatsapp/com.whatsapp.Conversation}} token= android.os.BinderProxy@b5b4175
2018-11-02 22:46:56.097 1052-3222/? V/WindowManager: removeAppToken: AppWindowToken{2882b98 token=Token{d0d617b ActivityRecord{71e050a u0 com.whatsapp/.Conversation t4923}}} delayed=false Callers=com.android.server.wm.DisplayContent.removeAppToken:1001 com.android.server.wm.AppWindowContainerController.removeContainer:281 com.android.server.am.ActivityRecord.removeWindowContainer:1051 com.android.server.am.ActivityStack.removeActivityFromHistoryLocked:4615

代码一夜之间停止工作很奇怪,也许 whatsapp 更新了并且这样做的 Intent 改变了

最佳答案

我不知道为什么你的代码不起作用,但我有另一种方法,试试这个:

private void accion_abrir_whatsapp(String num_telefono) {

boolean is_whatsapp_installed = appInstalledOrNot("com.whatsapp");
if(is_whatsapp_installed) {
Intent intent=new Intent(Intent.ACTION_VIEW,Uri.parse("https://api.whatsapp.com/send?phone="+num_telefono));
startActivity(intent);
}
else{
toast("No tienes instalado Whatsapp para esta accion");
}

}

注意:在此方法中,在 num_telefono 字符串中传递的号码应带有国家代码,例如,对于印度,它将是 91+“电话号码”。

关于android - 如何有意地在 whatsapp 中打开与特定号码的对话,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53128251/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com