【发布时间】:2014-06-02 14:54:06
【问题描述】:
我正在尝试从我的应用程序打开 Skype 聊天屏幕。如果未安装该应用程序,它会将您定向到 Playstore。我从这个链接使用它
http://developer.skype.com/skype-uris/skype-uri-tutorial-android
现在,每当单击 fb 按钮时,都必须调用initialSkypeUri() 方法。我在下面的代码中进行了尝试。我不知道我是否正确调用它。所以我需要一些指导?
public class About extends MainActivity implements android.view.View.OnClickListener
{
Button fb;
static String TAG = "remote it";
String mySkypeUri = "skype:aruzev?chat";
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View contentView = inflater.inflate(R.layout.about, null, false);
mDrawer.addView(contentView, 0);
fb = (Button) contentView.findViewById(R.id.fb);
fb.setOnClickListener(this);
}
public void onClick(View v)
{ // TODO Auto-generated method stub
if (v.getId() == R.id.fb)
{
startActivity(initiateSkypeUri(getApplicationContext(), mySkypeUri));
}
}
public void initiateSkypeUri(Context myContext, String mySkypeUri)
{
// Make sure the Skype for Android client is installed
if (!isSkypeClientInstalled(myContext))
{
goToMarket(myContext);
return;
}
// Create the Intent from our Skype URI
Uri skypeUri = Uri.parse(mySkypeUri);
Intent myIntent = new Intent(Intent.ACTION_VIEW, skypeUri);
// Restrict the Intent to being handled by the Skype for Android client
// only
myIntent.setComponent(new ComponentName("com.skype.raider", "com.skype.raider.Main"));
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// Initiate the Intent. It should never fail since we've already
// established the
// presence of its handler (although there is an extremely minute window
// where that
// handler can go away...)
myContext.startActivity(myIntent);
return;
}
public void goToMarket(Context myContext)
{
Uri marketUri = Uri.parse("market://details?id=com.skype.raider");
Intent myIntent = new Intent(Intent.ACTION_VIEW, marketUri);
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
myContext.startActivity(myIntent);
return;
}
public boolean isSkypeClientInstalled(Context myContext)
{
PackageManager myPackageMgr = myContext.getPackageManager();
try
{
myPackageMgr.getPackageInfo("com.skype.raider", PackageManager.GET_ACTIVITIES);
}
catch (PackageManager.NameNotFoundException e)
{
return (false);
}
return (true);
}
}
【问题讨论】:
-
这还能编译吗?