Jer*_*ith 7 java android android-activity
我想将调用活动与其他人进行比较,以了解哪一个称为当前活动.我试过了:
getCallingActivity().getClassName().toString().equals(MainActivity.class.toString())
Run Code Online (Sandbox Code Playgroud)
它不起作用,除了在调用Intent中传递一个值,我们如何使用getCallingActivity()或者比较类getCallingPackage()?
如果为另一个活动的结果启动了活动,则可以按以下方式比较呼叫活动.
if (getCallingActivity().getClassName().equals(MainActivity.class.getName())) {
/* here the main activity is calling activity*/
}else{
/*other activity is calling activity*/
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2156 次 |
| 最近记录: |