发送USSD code编程拨打代替普通电话的Skype普通、电话、USSD、code

2023-09-06 09:18:30 作者:故人叹

在运行此

String ussdCode = "*" + "100" + Uri.encode("#");
startActivity(new Intent("android.intent.action.CALL", Uri.parse("tel:" + ussdCode)));

我希望做一个正常的电话,但不是说Skype的去正面和拨打电话的* 100#USSD code。我从Skype的注销,其窗台带来的Skype到前!结果如何迫使它使用普通电话的替代Skype的?

I expect a normal phone call to be done, but instead of that Skype go to front and make the call for *100# USSD code. I logged out from Skype and it sill brings Skype to front!. How to force it to use the normal phone call instead of Skype?

推荐答案

那是因为你Skype帐户作为默认呼叫应用程序。这是一种设备配置。您可以在您的手机更多的改变,但必须注意,如果你做,它会actualy改变configation,因此Skype的不会是默认的。

Thats because you have Skype as the default application for calls. This is a device configuration. You can change it, but note that if you does, it will actualy change that configation, so skype wont be the default any more in your mobile.

您可以清除默认的应用程序调用此表格活动

You can clear the default application calling this form your activity

getPackageManager().clearPackagePreferredActivities(PACKAGENAME);

的Skype包名是com.skype.raider,所以你的情况,你把这个

the package name of skype is com.skype.raider, so in your case you call this

getPackageManager().clearPackagePreferredActivities("com.skype.raider");

当然,你叫什么你调用startActivity之前

of course you call it before you call the startActivity

更新

我记得,如果你不想要重置缺省配置,你可以尝试迫使一个应用程序来处理您发送给startActivity的意图。但是,你有问题,你必须知道应用程序的包名,以及活动应该处理它。在某些情况下,这将是很容易找出来,但在其他一些它不会。我一直在使用Google的这一信息对于默认的Andr​​oid拨号器,也看着我的设备,但我没有发现任何东西。不管怎么说,如果你能找到它,你可以使用下面的code,它会更好,因为它不会改变任何设置。你也可以记住它,因为它可以在其他情况下,是很方便的:

I remembered that if you don't want to reset default configuration, you can try to force one app to handle the intent you are sending to startActivity. But you have a problem, you will have to know the package name of the application, and the activity which should handle it. In some cases that will be easy to find out, but in some other it wont. I've been googling for this information for the default android dialer, and also looked in my device, but i didn't find anything. Anyways, if you can find it, you can use the code below and it will be much better since it doesn't change any setting. Also you can remember it since it could be handy in other situations:

Intent intent = new Intent();
intent.setComponent(new ComponentName("PACKAGE_NAME","PACKAGENAME.ACTIVITY_NAME"));
intent.setAction("android.intent.action.VIEW");
intent.addCategory("android.intent.category.BROWSABLE");
Uri uri = Uri.parse(url);
intent.setData(uri);
try
{
    startActivity(intent);
}
catch (Exception e)
{
   e.printStackTrace();
}