如何运行于Android按钮点击单独的应用程序 [英] How to run separate application from Android button click

查看:103
本文介绍了如何运行于Android按钮点击单独的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图添加两个按钮在我的Andr​​oid应用程序选择从图像中显示不同的两个应用程序订单系统和库存system.As的应用程序。

I tried to add two buttons in my Android application to select an application from separate two applications Order system and Inventory system.As shown in the image.

我已经实现了这两个应用程序作为单独的两款Android项目。当我尝试运行此应用程序涉及到的选择的窗口中正确,但是当一个按钮为pressed仿真器显示强制关闭的消息。
我增加了订单系统和库存系统项目首次应用的构建路径,然后导入他们的包(com.oms.ws和com.inv.ws)。这可能是不正确的,但不知道如何做到这一点。请帮帮我!我是新来的Andr​​oid系统。
我想用模拟器来测试这个应用程序!

I have implemented these two applications as separate two Android projects. When I try to run this application it comes until to the the selecting window correctly, but when one button is pressed emulator shows "Force Close" message. I have added Order system and Inventory system projects to first application's build path and then import their packages(com.oms.ws and com.inv.ws). This may be incorrect, but don't know how to do this. Please help me! I'm new to Android. I want to test this application using the emulator!

下面是code我已经习惯了选择应用程序。

Here is the code I have used to select applications.

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import com.oms.ws.*;

 public class ThirdScreen extends Activity {

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.thirdscreen);

    Button oms;
    oms = (Button)findViewById(R.id.orderSystem); 
    oms.setOnClickListener(ordrMnagemntSys);

    Button inventory;
    inventory = (Button)findViewById(R.id.inventorySystem); 
    inventory.setOnClickListener(inventorySys);

}

private OnClickListener ordrMnagemntSys = new OnClickListener(){
    public void onClick(View v) {

            Intent oMs = new Intent(getApplicationContext(), com.oms.ws.TestOms.class);
            startActivity(oMs);
            }
};

private OnClickListener inventorySys = new OnClickListener(){
    public void onClick(View v) {

            Intent inven = new Intent(getApplicationContext(), com.inv.ws.TestInventory.class);
            startActivity(inven);
            }
};
}

谢谢!

推荐答案

好这工作

Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("org.abc");
startActivity(LaunchIntent);

替换org.abc与您要启动的应用程序的包名。

Replace org.abc with package name of the application which you want to start.

这篇关于如何运行于Android按钮点击单独的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆