只有Skype在后台运行时才会发生Android Skype通话

时间:2014-02-11 23:52:57

标签: android skype

我在Android按键点击时使用Skype拨打电话。以下是启动Skype意图的代码:

Uri skypeUri = Uri.parse(uri.toString());
Intent myIntent = new Intent("android.intent.action.CALL_PRIVILEGED", skypeUri);
myIntent.setComponent(new ComponentName("com.skype.raider", "com.skype.raider.Main"));
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(myIntent);

第一次运行时,它只是在不打电话的情况下启动Skype应用程序。当我在后台启动Skype时,它会拨打该号码。我希望用户每次都拨打该号码,而不是从第二次开始拨号,但是现在Skype呼叫只在Skype已经在后台运行时才会发生。

有什么建议吗?

2 个答案:

答案 0 :(得分:0)

我使用此代码启动Skype调用,它对我来说没问题(每次调用都会启动):

Uri skypeUri = Uri.parse(mySkypeUri);
Intent myIntent = new Intent(Intent.ACTION_VIEW, skypeUri);

myIntent.setComponent(new ComponentName("com.skype.raider", "com.skype.raider.Main"));
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
myContext.startActivity(myIntent);

uri应该看起来像这样:  SKYPE:?skype_contact呼叫

请参阅此处的msdn文章:Skype URI tutorial: Android apps

答案 1 :(得分:-1)

我建议你启动skype calll,如下所述,它来自我的GitHub存储库Skype-Call-Demo。你也可以下载它。

代码:

    public class MainActivity extends Activity {

    private static final String TAG = "MainActivity";
    private Context mContext;
    private EditText etRecepient;
    private Button btnSkypeCall;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initialize();
    }

    private void initialize() {
        mContext=this;
        etRecepient = (EditText)findViewById(R.id.etRecepient);
        btnSkypeCall = (Button)findViewById(R.id.btnSkypeCall);
        btnSkypeCall.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                skypeCall(etRecepient.getText().toString(), mContext);
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

    private static void goToMarket(Context ctx) {
        // TODO Auto-generated method stub
          Uri marketUri = Uri.parse("https://play.google.com/store/apps/details?id=com.skype.raider");
          Intent myIntent = new Intent(Intent.ACTION_VIEW, marketUri);
          myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          ctx.startActivity(myIntent);

          return;
    }

    private static boolean isSkypeClientInstalled(Context ctx) {
        PackageManager myPackageMgr = ctx.getPackageManager();
          try {
            myPackageMgr.getPackageInfo("com.skype.raider", PackageManager.GET_ACTIVITIES);
          }
          catch (PackageManager.NameNotFoundException e) {
            return (false);
          }
          return (true);
    }



    private static void skypeCall(String name, Context ctx) {
        try {
            if (!isSkypeClientInstalled(ctx)) {
                goToMarket(ctx);
                return;
              }

/*          Intent skype_intent = new Intent("android.intent.action.CALL_PRIVILEGED");
            skype_intent.setClassName("com.skype.raider","com.skype.raider.Main");
            skype_intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
            skype_intent.setData(uri); 
*/            
            Intent skype_intent = new Intent("android.intent.action.VIEW");
            Uri uri=Uri.parse("skype:"+name+"?call&video=true");
            skype_intent.setData(uri);
            ctx.startActivity(skype_intent);
        } catch (ActivityNotFoundException e) {
            Log.e("SKYPE CALL", "Skype failed", e);
        }

    }

}

编辑:

尝试一下,我不确定。

我已经取代了

                Uri uri=Uri.parse("skype:"+name);

                Uri uri=Uri.parse("skype:"+name+"?call&video=true");

参考:

Explicit Skype URI