每次我从应用模块调用库模块上的活动时,应用都会崩溃
应用模块上有一个按钮,当它被按下时,它将调用库模块中的活动,但是每次我这样做,应用都会崩溃
下面是应用模块上的代码,意图将在其中调用库模块上的主要活动
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS 10.14.2
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] cowplot_0.9.3 forcats_0.3.0 stringr_1.3.1 dplyr_0.7.6 purrr_0.2.5 readr_1.1.1 tidyr_0.8.1
[8] tibble_1.4.2 ggplot2_3.0.0 tidyverse_1.2.1
loaded via a namespace (and not attached):
[1] Rcpp_0.12.17 cellranger_1.1.0 pillar_1.3.0 compiler_3.5.1 plyr_1.8.4 bindr_0.1.1
[7] tools_3.5.1 jsonlite_1.5 lubridate_1.7.4 nlme_3.1-137 gtable_0.2.0 lattice_0.20-35
[13] pkgconfig_2.0.1 rlang_0.2.1.9000 cli_1.0.0 rstudioapi_0.7 yaml_2.1.19 haven_1.1.2
[19] bindrcpp_0.2.2 withr_2.1.2 xml2_1.2.0 httr_1.3.1 hms_0.4.2 grid_3.5.1
[25] tidyselect_0.2.4 glue_1.3.0 R6_2.2.2 fansi_0.2.3 readxl_1.1.0 modelr_0.1.2
[31] magrittr_1.5 backports_1.1.2 scales_0.5.0 rvest_0.3.2 assertthat_0.2.0 colorspace_1.3-2
[37] labeling_0.3 utf8_1.1.4 stringi_1.2.4 lazyeval_0.2.1 munsell_0.5.0 broom_0.5.0
[43] crayon_1.3.4
这是应用模块上的android清单
//Audio Activity
audioButton = (ImageView) findViewById(R.id.IV_main_audio);
audioButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
Intent intentLoadNewActivity = new
Intent("com.danielkim.soundrecorder.MainActivity");
startActivity(intentLoadNewActivity);
}
});
答案 0 :(得分:0)
糟糕的是,反射可以用来从libary模块启动您的Activity:
Class.forName(“ com.mypackage.MainActivity”)
try {
Intent myIntent = new
Intent(this,Class.forName("com.danielkim.soundrecorder.MainActivity"));
startActivity(myIntent);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
答案 1 :(得分:0)
Intent i=new Intent(PresentActivity.this, NextActivity.class);
startActivity(i);
答案 2 :(得分:0)
audioButton = (ImageView) findViewById(R.id.IV_main_audio);
audioButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
try{
// try another constructor
Intent intentLoadNewActivity = new Intent(v.getContext(), "com.danielkim.soundrecorder.MainActivity");
// add optional flag FLAG_ACTIVITY_NEW_TASK if necessary.
// intentLoadNewActivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intentLoadNewActivity);
} catch (Exception e) {
Log.e("TAG",e);// if still not work, please show us the log.
}
}
});
答案 3 :(得分:0)
(代表问题作者发布的解决方案)。
经过一些搜索,我已经解决了。我只是在app模块和库模块上有一个重复的文件名。