gpt4 book ai didi

android - 我怎样才能对图书馆的 Activity 做出 Intent ?

转载 作者:行者123 更新时间:2023-11-29 15:38:21 27 4
gpt4 key购买 nike

我创建了一个库项目,然后构建它,获取 .aar 并解压缩它。获取包含库的 classes.jar 文件,并将其添加到另一个项目中。该项目识别我的文件,我可以从中调用方法和函数。我的问题是我尝试从我的库中调用一个 Activity 的 Intent ,如下所示:

 textView = (TextView) findViewById(R.id.text);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, InCallActivity.class);
intent.putExtra("duration",20);
intent.putExtra("message","test");
intent.putExtra("url","https://facetalk.vidyo-nl.com/mobile.html?roomdirect.html&key=QMvMp3eKTqOeLAWQ6HOvHqFJd0");
intent.putExtra("test","true");
startActivity(intent);
}
});

但是我遇到这样的问题:

08-10 15:02:41.730: E/AndroidRuntime(18572): Process: com.vidyo.facetalklibtest, PID: 18572
08-10 15:02:41.730: E/AndroidRuntime(18572): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.vidyo.facetalklibtest/com.vidyo.vidyocore.activities.InCallActivity}; have you declared this activity in your AndroidManifest.xml?
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1794)
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1512)
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.app.Activity.startActivityForResult(Activity.java:3930)
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.app.Activity.startActivityForResult(Activity.java:3890)
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.app.Activity.startActivity(Activity.java:4213)
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.app.Activity.startActivity(Activity.java:4181)
08-10 15:02:41.730: E/AndroidRuntime(18572): at com.vidyo.facetalklibtest.MainActivity$1.onClick(MainActivity.java:32)
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.view.View.performClick(View.java:5204)
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.view.View$PerformClick.run(View.java:21153)
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.os.Handler.handleCallback(Handler.java:739)
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.os.Handler.dispatchMessage(Handler.java:95)
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.os.Looper.loop(Looper.java:148)
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.app.ActivityThread.main(ActivityThread.java:5417)
08-10 15:02:41.730: E/AndroidRuntime(18572): at java.lang.reflect.Method.invoke(Native Method)
08-10 15:02:41.730: E/AndroidRuntime(18572): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
08-10 15:02:41.730: E/AndroidRuntime(18572): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
08-10 15:02:41.731: W/ActivityManager(787): Force finishing activity com.vidyo.facetalklibtest/.MainActivity

现在我发现了一些关于需要在 project.properties 文件中设置的 list 合并 manifestmerger.enabled=true 的内容。但是我正在使用 AndroidStudio,而不是 Eclipse,因此我没有那个文件。我该如何解决这个问题?

最佳答案

<activity
android:name=".MainActivity">
<intent-filter>
<action android:name="com.example.main.mainactivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

在你的库中只需调用它来打开 MainActivity:

Intent intent = new Intent("com.example.main.mainactivity");
startActivity(intent);

关于android - 我怎样才能对图书馆的 Activity 做出 Intent ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45614620/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com