简体   繁体   English

来自Modul的Android Studio Start Activity

[英]Android Studio Start Activity from Modul

I have created an *.aar File from a Android Studio project. 我已经从Android Studio项目创建了一个* .aar文件。 This file I have successfully imported to an another Android Studio project file. 我已成功导入此文件到另一个Android Studio项目文件。 Now I want start the activity from the included libraries. 现在我想从包含的库中启动活动。 But i am hanging and I try hour to hour... 但我挂了,我每小时都在尝试......

In wich file I have to include the statement like this? 在wich文件中我必须包含这样的声明?

 public void button_to_start_the_activity(View view)
{
    Intent intent = new Intent(StartActivity.this, MainActivity.class);
    startActivity(intent);
}

Should I implement this in the modul java file or in the application java file? 我应该在模块java文件或应用程序java文件中实现它吗? (Please check this out, I have not found a activity java file in my module :-/ glglgl) Steps bevor, i have created a new activity in my main-project and i was able to start the activity without trouble. (请检查一下,我没有在我的模块中找到一个活动java文件: - / glglgl)步骤bevor,我在我的主项目中创建了一个新活动,我能够毫无困难地启动活动。

Okay... Next question: 好的...下一个问题:

In the Main Manifest,...what to hell I shout declare in android:name"....?...." like this: 在Main Manifest中,...我该怎么回事我在android中声明:名字“....?....”像这样:

<activity
        android:name="....??????...."
        android:label="DLC"
        android:screenOrientation="portrait"
        android:theme="@style/Theme.AppCompat.NoActionBar">
    </activity>

Maybe, or for sure, simple question... But i try to learn a little bit AS since a week... For your understanding, i will try to explain my project with simple words....: 也许,或者肯定是一个简单的问题...但是我试着从一周开始学习一点AS ...为了你的理解,我会尝试用简单的词语来解释我的项目......:

Try to merge two app projects in one app! 尝试在一个应用中合并两个应用程序项目!

I have created a app, then i have created an another app. 我创建了一个应用程序,然后我创建了另一个应用程序。 Now i want to merge. 现在我想合并。 Simple startpage (allready exist) with the function to call the both activitys... :-/ 简单的初始化(已经存在),具有调用两个活动的功能...: - /

My final solution to start a modul activity in the main app (For poeple with less experience like me) 我在主应用程序中启动模块活动的最终解决方案(对于像我这样经验较少的人)

  1. Create in Android Studio a modul from the existing app 在Android Studio中创建现有应用程序的模块
  2. Open Main-Project an insert the new modul (File-->New-->Import Modul) 打开Main-Project插入新模块(File - > New - > Import Modul)
  3. Right click on project folder. 右键单击项目文件夹。 Search App (left side), then dependencies (right side) --> Add new from modul --> Add your modul 搜索应用程序(左侧),然后依赖项(右侧) - >从模块添加新项目 - >添加您的模块
  4. Check your build.cradle (Main-App) for compile project(':yourmodul') 检查build.cradle(Main-App)以获取编译项目(':yourmodul')
  5. Add this in your activity (from the Main-App) 在您的活动中添加此内容(来自主应用程序)

      public class StartActivity extends AppCompatActivity { public void gotocalc(View view) { Intent intent = new Intent(StartActivity.this, YourModulClass.class); startActivity(intent); } 
  6. gotocalc is for start with a button android:onClick="gotocalc" set in your layout.xml in the Main App. gotocalc是在主应用程序的layout.xml中设置按钮android:onClick =“gotocalc”的开始。

  7. Clean, Rebuild 清洁,重建

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM