本文整理匯總了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);
}