本文整理汇总了Java中android.app.Activity.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java Activity.getParent方法的具体用法?Java Activity.getParent怎么用?Java Activity.getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.Activity
的用法示例。
在下文中一共展示了Activity.getParent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bindToService
import android.app.Activity; //导入方法依赖的package包/类
public static ServiceToken bindToService(Activity context,
ServiceConnection callback) {
Activity realActivity = context.getParent();
if (realActivity == null) {
realActivity = context;
}
ContextWrapper cw = new ContextWrapper(realActivity);
cw.startService(new Intent(cw, MediaPlaybackService.class));
ServiceBinder sb = new ServiceBinder(callback);
if (cw.bindService(
(new Intent()).setClass(cw, MediaPlaybackService.class), sb, 0)) {
sConnectionMap.put(cw, sb);
return new ServiceToken(cw);
}
return null;
}
示例2: scanForActivity
import android.app.Activity; //导入方法依赖的package包/类
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");
}
示例3: getBreadcrumbs
import android.app.Activity; //导入方法依赖的package包/类
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);
}