我正在做一個Android應用程序,以我的書,我有一個HTML頁面我要添加按鈕就可以鏈接到這個Java代碼鏈接HTML按鈕的Java活動
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// listeners of our two buttons
View.OnClickListener handler = new View.OnClickListener() {
public void onClick(View v) {
switch (v.getId()) {
case R.id.buttonShareTextUrl:
shareTextUrl();
break;
}
}
};
// our buttons
findViewById(R.id.buttonShareTextUrl).setOnClickListener(handler);
}
// Method to share either text or URL.
private void shareTextUrl() {
Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("text/plain");
share.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
// Add data to the intent, the receiving app will decide
// what to do with it.
share.putExtra(Intent.EXTRA_SUBJECT, "book");
share.putExtra(Intent.EXTRA_TEXT, "https://play.google.com/store/apps/details?id=com.sohaibm.assrar_bac");
startActivity(Intent.createChooser(share, "share with"));
}
}
所以我要你給我一個包含鏈接到本次活動的按鈕頁面的HTML代碼,並感謝你這麼多
它didint工作,我puted第一代碼001.htm 的我創建FirstACtivity.java我puted第二個代碼在應用程序中我只有一個按鈕,當我clilck沒有發生什麼事情我該怎麼辦 – Sohaibm96