本文整理了Java中android.app.Activity.getParent()
方法的一些代码示例,展示了Activity.getParent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.getParent()
方法的具体详情如下:
包路径:android.app.Activity
类名称:Activity
方法名:getParent
暂无
代码示例来源:origin: naman14/Timber
public static final ServiceToken bindToService(final Context context,
final ServiceConnection callback) {
Activity realActivity = ((Activity) context).getParent();
if (realActivity == null) {
realActivity = (Activity) context;
}
final ContextWrapper contextWrapper = new ContextWrapper(realActivity);
contextWrapper.startService(new Intent(contextWrapper, MusicService.class));
final ServiceBinder binder = new ServiceBinder(callback,
contextWrapper.getApplicationContext());
if (contextWrapper.bindService(
new Intent().setClass(contextWrapper, MusicService.class), binder, 0)) {
mConnectionMap.put(contextWrapper, binder);
return new ServiceToken(contextWrapper);
}
return null;
}
代码示例来源:origin: aa112901/remusic
public static final ServiceToken bindToService(final Context context,
final ServiceConnection callback) {
Activity realActivity = ((Activity) context).getParent();
if (realActivity == null) {
realActivity = (Activity) context;
}
final ContextWrapper contextWrapper = new ContextWrapper(realActivity);
contextWrapper.startService(new Intent(contextWrapper, MediaService.class));
final ServiceBinder binder = new ServiceBinder(callback,
contextWrapper.getApplicationContext());
if (contextWrapper.bindService(
new Intent().setClass(contextWrapper, MediaService.class), binder, 0)) {
mConnectionMap.put(contextWrapper, binder);
return new ServiceToken(contextWrapper);
}
return null;
}
代码示例来源:origin: stackoverflow.com
Activity a = this;
while(a.getParent() != null) {
a = a.getParent();
}
_nicuWebView.setContext(a);
代码示例来源:origin: robolectric/robolectric
@Test
public void getAndSetParentActivity_shouldWorkForTestingPurposes() throws Exception {
Activity parentActivity = new Activity();
Activity activity = new Activity();
shadowOf(activity).setParent(parentActivity);
assertSame(parentActivity, activity.getParent());
}
代码示例来源:origin: stackoverflow.com
Activity a = this;
while(a.getParent() != null) {
Log.i("ActivityTree",a.getClass().getSimpleName());
a = a.getParent();
}
_nicuWebView.setContext(a);
代码示例来源:origin: typ0520/fastdex
static void updateActivity(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
if (Log.isLoggable(Logging.LOG_TAG, Log.VERBOSE)) {
Log.v(Logging.LOG_TAG, "About to restart " + activity.getClass().getSimpleName());
}
// You can't restart activities that have parents: find the top-most activity
while (activity.getParent() != null) {
if (Log.isLoggable(Logging.LOG_TAG, Log.VERBOSE)) {
Log.v(Logging.LOG_TAG, activity.getClass().getSimpleName()
+ " is not a top level activity; restarting "
+ activity.getParent().getClass().getSimpleName() + " instead");
}
activity = activity.getParent();
}
// Directly supported by the framework!
activity.recreate();
}
}
代码示例来源:origin: stackoverflow.com
public Context getDialogContext(Activity act) {
Context context;
if (act.getParent() != null)
context = act.getParent();
else context = act;
return context;
}
代码示例来源:origin: com.uphyca/android-junit4-robolectric
/**
* @return
* @see android.app.Activity#getParent()
*/
public final Activity getParent() {
return mActivity.getParent();
}
代码示例来源:origin: stackoverflow.com
final Activity activity = SearchActivity.activity //parent Activity;
final TabHost tabHost = (TabHost) activity.getParent().findViewById(android.R.id.tabhost);
代码示例来源:origin: limboemu/limbo
@Override
public void onCancel(DialogInterface dialog) {
if (LimboSettingsManager.isFirstLaunch(activity)) {
if (activity.getParent() != null) {
activity.getParent().finish();
} else {
activity.finish();
}
}
}
});
代码示例来源:origin: limboemu/limbo
public void onClick(DialogInterface dialog, int which) {
Log.i(TAG, "VM Paused, Shutting Down");
if (LimboActivity.vmexecutor != null) {
LimboActivity.vmexecutor.stopvm(0);
} else if (activity.getParent() != null) {
activity.getParent().finish();
} else {
activity.finish();
}
}
}).show();
代码示例来源:origin: stackoverflow.com
public static void closeAllBelowActivities(Activity current) {
boolean flag = true;
Activity below = current.getParent();
if (below == null)
return;
System.out.println("Below Parent: " + below.getClass());
while (flag) {
Activity temp = below;
try {
below = temp.getParent();
temp.finish();
} catch (Exception e) {
flag = false;
}
}
}
代码示例来源:origin: tohodog/QSVideoPlayer
public static Activity scanForActivity(Context context) {
if (context instanceof Activity) {
Activity a = (Activity) context;
if (a.getParent() != null)
return a.getParent();
else
return a;
} else if (context instanceof ContextWrapper) {
return scanForActivity(((ContextWrapper) context).getBaseContext());
}
throw new IllegalStateException("context得不到activity");
}
代码示例来源:origin: stackoverflow.com
public static Activity goUp(Activity current){
if(current.getParent()!=null){
current=current.getParent();
goUp(current);
}
return current;
}
ProgressDialog progressDialog = ProgressDialog.show(goUp(MyActivity.this), "Loading...", "Please wait...");
代码示例来源:origin: stackoverflow.com
Activity ac = (Activity) context;
ActivityGroup ag = (ActivityGroup) ac.getParent();
Intent i = new Intent(SummaryCostScreen.this,PermissionsScreen.class);
View view = ag.getLocalActivityManager().startActivity("activity9",i.addFlags
(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
this.setContentView(view);
代码示例来源:origin: stackoverflow.com
public static Context goUp(Activity current){
if(current.getParent()!=null){
current=current.getParent();
goUp(current);
}
return current.getBaseContext();
}
assignment = new DbAdapter_Assignment(goUp(TaskDetailTabHome.this));
assignment.open();
代码示例来源:origin: matomo-org/piwik-sdk-android
public static String getBreadcrumbs(final Activity activity) {
Activity currentActivity = activity;
ArrayList<String> breadcrumbs = new ArrayList<>();
while (currentActivity != null) {
breadcrumbs.add(currentActivity.getTitle().toString());
currentActivity = currentActivity.getParent();
}
return joinSlash(breadcrumbs);
}
代码示例来源:origin: matomo-org/matomo-sdk-android
public static String getBreadcrumbs(final Activity activity) {
Activity currentActivity = activity;
ArrayList<String> breadcrumbs = new ArrayList<>();
while (currentActivity != null) {
breadcrumbs.add(currentActivity.getTitle().toString());
currentActivity = currentActivity.getParent();
}
return joinSlash(breadcrumbs);
}
代码示例来源:origin: baidu/GPT
/**
* 替换目标对象的window。
*
* @param activity Activity
*/
private static void replaceWindow(Activity activity) {
Activity parent = activity.getParent();
if (parent != null && parent instanceof ActivityProxy) {
JavaCalls.setField(activity, "mWindow", parent.getWindow());
}
replaceWindowCallback(activity);
}
代码示例来源:origin: baidu/GPT
/**
* initActionBar
*/
private void initActionBar() {
int SDK_INT = android.os.Build.VERSION.SDK_INT;
if (SDK_INT >= 11) {
ActionBar actionBar = mActivity.getParent().getActionBar();
JavaCalls.setField(mActivity, "mActionBar", actionBar);
}
}
内容来源于网络,如有侵权,请联系作者删除!