Android的,我怎么能使用外部APK在我的应用程序? [英] Android, How can I use external APK in my application?

查看:238
本文介绍了Android的,我怎么能使用外部APK在我的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了两个项目。第一个,提取手持机的信息,并显示在屏幕上。我有这个项目的.apk文件(例如 test.apk )。

I have created two projects. The first one, extracts information of handset and shows on the screen. I have .apk file of this project (for example test.apk).

然后,我创建了第二个项目。这其中的屏幕上有一个按钮,我想,当我按一下按钮,第一个项目运行(显示手机信息)。我加入test.apk到这个项目通过项目的根右键点击>构建路径>配置构建路径>添加外部JAR> test.apk

Then I created second project. This one has a button on the screen and I want when I click the button, first project runs (shows information of handset). I have added test.apk into this project by right clicking on root of project>Build Path>Configure Build Path>Add External JARs>test.apk

然后在code,我用的意图称为这一点。这是我的code:

Then in the code, I called this by using intent. this is my code:

btn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent("com.in.test.MainActivity"); 
                startActivity(intent);
            }
        });

然而,当我运行应用程序,根据logcat中,我看到下面的错误:
10月11日至18日:09:28.933:E / AndroidRuntime(2237):未捕获的处理程序:螺纹主力退出,由于未捕获的异常
10月11日至18日:09:29.022:E / AndroidRuntime(2237):android.content.ActivityNotFoundException:无活动处理意向{行动= com.in.test.MainActivity}
10月11日至18日:09:29.022:E / AndroidRuntime(2237):在android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1484)



however, when I run the application, according to logcat, I see following error: 11-18 10:09:28.933: E/AndroidRuntime(2237): Uncaught handler: thread main exiting due to uncaught exception 11-18 10:09:29.022: E/AndroidRuntime(2237): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.in.test.MainActivity } 11-18 10:09:29.022: E/AndroidRuntime(2237): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1484) . . .

什么,在哪里是我的问题?
谢谢

What and where is my problem? Thanks

更新:
在manifest文件中添加此行的内部应用元素:

<activity
            android:name="com.in.test.MainActivity" />

但结果还是一样。我会尝试按照你的建议(使用意图过滤器)。

but the result is still the same. I'll try to follow your suggestion (using intent filter).

推荐答案

要像你正在做的(在构造函数中使用的活性类)有明确的意图开始一项活动,该活动必须在清单您的声明应用程序必须得到遵守到您的应用程序。您不能使用一个单独的apk文件为。

To start an activity with an explicit intent like you are doing (by using the activity class in the constructor), the activity must be declared in the manifest for your app and must be complied into your app. You cannot use a separate apk file for that.

做你想要的东西的方式是声明在test.apk活动的意图过滤器和使用适当的意图来运行它。见引导话题意图和意图过滤器和用于文档意向类有关如何操作的更多信息。

The way to do what you want is to declare an intent filter for the activity in test.apk and to launch it using an appropriate intent. See the guide topic Intents and Intent Filters and the documentation for the Intent class for more information about how to do this.

这篇关于Android的,我怎么能使用外部APK在我的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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