当我导航到about us菜单时,我的应用程序遇到了自动打开网页到instagram的问题。我只希望在用户点击Instagram文本后发生这种情况,因此它提供了使用insta应用程序或在网页中打开Instagram的选项 关于如何解决这个问题的任何想法?
具有将用户发送到相应应用的意图的活动
package com.example.vitoriano_vaz.eastbayvapes;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
public class AboutActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
Uri number = Uri.parse("tel:9259519029");
Intent callIntent = new Intent(Intent.ACTION_DIAL, number);
Uri webpage = Uri.parse("http://www.facebook.com/eastbay");
Intent webIntent = new Intent(Intent.ACTION_VIEW, webpage);
// intent to send user to instagram
Uri uri = Uri.parse("http://instagram.com/_u/eastbay");
final Intent likeIng = new Intent(Intent.ACTION_VIEW, uri);
likeIng.setPackage("com.instagram.android");
try {
startActivity(likeIng);
} catch (ActivityNotFoundException e) {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://instagram.com/eastbay")));
}
TextView instaText = (TextView)findViewById(R.id.textView8);
instaText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
startActivity(likeIng);
} catch (ActivityNotFoundException e) {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://instagram.com/eastbay")));
}
}
});
//Intent to send user to email app
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("plain/text");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"eastbay@gmail.com"});
intent.putExtra(Intent.EXTRA_SUBJECT, "subject");
intent.putExtra(Intent.EXTRA_TEXT, "");
startActivity(Intent.createChooser(intent, ""));
}
}
答案 0 :(得分:0)
您需要在活动主体内部的onclick侦听器内启动活动。你需要为你的邮件意图做同样的事情,这也是你的oncreate。
SendKeys