本文介绍了如何使一个按钮,打开与Java / Android的另一个应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我努力学习做一个简单的应用程序,与每个打开另一个应用程序,无需再应用程序的几个按钮。我只是不明白。另外,我可以放置多个按钮,本次活动以打开另一个应用程序?我真的不能找到答案无论是。

I am trying to learn to make a simple app that has a few buttons with each opening another app to eliminate the need for another apps. I just can't figure it out. Also, can I place more than one button in this activity to open another app? I can't really find that answer either.

Button batteryhistory = (Button)findViewById(R.string.BatteryHistoryButtonDialog);

    batteryhistory.setOnClickListener(new View.OnClickListener() {

      @Override
      public void onClick(View view) {
      Intent i = new Intent();
       ComponentName n = new
       ComponentName("com.android.settings",
       "com.android.settings.BatteryHistory");
       i.setComponent(n);
       startActivity(i);

感谢这么多的帮助:D

Thanks so much for the help :D

推荐答案

希望这个实现将工作:

if (v.getId() == R.id.ImageButton01) {

            if (keyCode == KeyEvent.KEYCODE_ENTER) {
                // Toast.makeText(this, "Application Name", Toast.LENGTH_LONG).show();
                Intent i = new Intent();
                i.setAction(Intent.ACTION_VIEW);
                i.setClassName("com.xxx.your_package_name",
                        "com.xxx.your_class_name");

                startActivity(i);

            }
        }

的唯一的事情是,你必须安装前手的应用程序。

The only thing is that you will have to install the application before hand.

这篇关于如何使一个按钮,打开与Java / Android的另一个应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 03:08