本文整理汇总了C++中AutoPtr::AddCategory方法的典型用法代码示例。如果您正苦于以下问题:C++ AutoPtr::AddCategory方法的具体用法?C++ AutoPtr::AddCategory怎么用?C++ AutoPtr::AddCategory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoPtr
的用法示例。
在下文中一共展示了AutoPtr::AddCategory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
AutoPtr<IIntent> MonkeyActivityEvent::GetEvent()
{
AutoPtr<IIntent> intent;
CIntent::New(IIntent::ACTION_MAIN, (IIntent**)&intent);
intent->AddCategory(IIntent::CATEGORY_LAUNCHER);
intent->SetComponent(mApp);
intent->AddFlags(IIntent::FLAG_ACTIVITY_NEW_TASK |
IIntent::FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
return intent;
}
示例2: OnLongClick
ECode LocalViewOnLongClickListener::OnLongClick(
/* [in] */ IView* v,
/* [out] */ Boolean* result)
{
// try {
AutoPtr<IIntent> intent;
CIntent::New(IIntent::ACTION_MAIN, (IIntent**)&intent);
intent->SetFlags(IIntent::FLAG_ACTIVITY_NEW_TASK
| IIntent::FLAG_ACTIVITY_CLEAR_TASK
| IIntent::FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
intent->AddCategory(String("com.android.internal.category.PLATLOGO"));
mHost->StartActivity(intent);
//.setClassName("com.android.systemui","com.android.systemui.BeanBag"));
// } catch (ActivityNotFoundException ex) {
// android.util.Log.e("PlatLogoActivity", "Couldn't find a bag of beans.");
// }
mHost->Finish();
*result = TRUE;
return NOERROR;
}
示例3: GetMainApps
/**
* Using the restrictions provided (categories & packages), generate a list
* of activities that we can actually switch to.
*
* @return Returns TRUE if it could successfully build a list of target
* activities
*/
Boolean Monkey::GetMainApps()
{
AutoPtr<IUserHandleHelper> helper;
CUserHandleHelper::AcquireSingleton((IUserHandleHelper**)&helper);
Int32 myUserId;
helper->GetMyUserId(&myUserId);
List<String>::Iterator it = mMainCategories->Begin();
const Int32 N = mMainCategories->GetSize();
for (; it != mMainCategories->End(); ++it) {
String category = *it;
AutoPtr<IIntent> intent;
CIntent::New(IIntent::ACTION_MAIN, (IIntent**)&intent);
if (!category.IsNullOrEmpty()) {
intent->AddCategory(category);
}
AutoPtr<IObjectContainer> mainApps;
mPm->QueryIntentActivities(intent, String(), 0, myUserId, (IObjectContainer**)&mainApps);
Int32 count;
if (!mainApps || (mainApps->GetObjectCount(&count), count == 0)) {
PFL_EX("// Warning: no activities found for category %s", category.string());
continue;
}
if (mVerbose >= 2) { // very verbose
PFL_EX("// Selecting main activities from category %s", category.string());
}
AutoPtr<IObjectEnumerator> enumerator;
mainApps->GetObjectEnumerator((IObjectEnumerator**)&enumerator);
Boolean hasNext = FALSE;
while (enumerator->MoveNext(&hasNext), hasNext) {
AutoPtr<IInterface> element;
enumerator->Current((IInterface**)&element);
AutoPtr<IResolveInfo> r = IResolveInfo::Probe(element);
String packageName;
AutoPtr<IActivityInfo> act;
r->GetActivityInfo((IActivityInfo**)&act);
AutoPtr<IApplicationInfo> appInfo;
act->GetApplicationInfo((IApplicationInfo**)&appInfo);
appInfo->GetPackageName(&packageName);
String actName;
act->GetName(&actName);
if (CheckEnteringPackage(packageName)) {
if (mVerbose >= 2) { // very verbose
PFL_EX("// + Using main activity %s (from package %s)", actName.string(), packageName.string());
}
AutoPtr<IComponentName> ele;
CComponentName::New(packageName, actName, (IComponentName**)&ele);
mMainApps->PushBack(ele);
}
else {
if (mVerbose >= 3) { // very very verbose
PFL_EX("// - NOT USING main activity %s (from package %s)",
actName.string(), packageName.string());
}
}
} //end while
}
if (mMainApps->IsEmpty()) {
PFL_EX("** No activities found to run, monkey aborted.");
return FALSE;
}
return TRUE;
}
示例4: ReloadButtons
void RecentApplicationsDialog::ReloadButtons()
{
AutoPtr<IContext> context = GetContext();
AutoPtr<IPackageManager> pm;
context->GetPackageManager((IPackageManager**)&pm);
AutoPtr<IInterface> tmpObj;
context->GetSystemService(IContext::ACTIVITY_SERVICE, (IInterface**)&tmpObj);
AutoPtr<IActivityManager> am = IActivityManager::Probe(tmpObj.Get());
AutoPtr<IObjectContainer> recentTasks;
am->GetRecentTasks(MAX_RECENT_TASKS, IActivityManager::RECENT_IGNORE_UNAVAILABLE,
(IObjectContainer**)&recentTasks);
AutoPtr<IActivityInfo> homeInfo;
AutoPtr<IIntent> intent;
CIntent::New(IIntent::ACTION_MAIN, (IIntent**)&intent);
intent->AddCategory(IIntent::CATEGORY_HOME);
intent->ResolveActivityInfo(pm, 0, (IActivityInfo**)&homeInfo);
AutoPtr<IconUtilities> iconUtilities = new IconUtilities(context);
// Performance note: Our android performance guide says to prefer Iterator when
// using a List class, but because we know that getRecentTasks() always returns
// an ArrayList<>, we'll use a simple index instead.
AutoPtr<IObjectEnumerator> enumerator;
recentTasks->GetObjectEnumerator((IObjectEnumerator**)&enumerator);
Int32 flags = 0;
Int32 i = 0;
Int32 index = 0;
Boolean hasNext = FALSE;
while ((enumerator->MoveNext(&hasNext), hasNext) && (index < NUM_BUTTONS)) {
AutoPtr<IInterface> obj;
enumerator->Current((IInterface**)&obj);
AutoPtr<IActivityManagerRecentTaskInfo> info = IActivityManagerRecentTaskInfo::Probe(obj.Get());
// for debug purposes only, disallow first result to create empty lists
if (DBG_FORCE_EMPTY_LIST && (i == 0)) {
++i;
continue;
}
AutoPtr<IIntent> newIntent, baseIntent;
info->GetBaseIntent((IIntent**)&baseIntent);
CIntent::New(baseIntent, (IIntent**)&newIntent);
AutoPtr<IComponentName> cn;
info->GetOrigActivity((IComponentName**)&cn);
if (cn != NULL) {
newIntent->SetComponent(cn);
}
// Skip the current home activity.
if (homeInfo != NULL) {
String pkgName, name, intentPkgName, intentClsName;
homeInfo->GetPackageName(&pkgName);
homeInfo->GetName(&name);
AutoPtr<IComponentName> cn;
newIntent->GetComponent((IComponentName**)&cn);
cn->GetPackageName(&intentPkgName);
cn->GetClassName(&intentClsName);
if (pkgName.Equals(intentPkgName) && name.Equals(intentClsName)) {
++i;
continue;
}
}
newIntent->GetFlags(&flags);
newIntent->SetFlags((flags & ~IIntent::FLAG_ACTIVITY_RESET_TASK_IF_NEEDED)
| IIntent::FLAG_ACTIVITY_NEW_TASK);
AutoPtr<IResolveInfo> resolveInfo;
pm->ResolveActivity(newIntent, 0, (IResolveInfo**)&resolveInfo);
if (resolveInfo != NULL) {
AutoPtr<IActivityInfo> activityInfo;
resolveInfo->GetActivityInfo((IActivityInfo**)&activityInfo);
AutoPtr<ICharSequence> seq;
activityInfo->LoadLabel(pm, (ICharSequence**)&seq);
String title;
seq->ToString(&title);
AutoPtr<IDrawable> icon;
activityInfo->LoadIcon(pm, (IDrawable**)&icon);
if (!title.IsNull() && title.GetLength() > 0 && icon != NULL) {
AutoPtr<ITextView> tv = (*mIcons)[index];
tv->SetText(seq);
icon = iconUtilities->CreateIconDrawable(icon);
tv->SetCompoundDrawables(NULL, icon, NULL, NULL);
AutoPtr<RecentTag> tag = new RecentTag();
tag->mInfo = info;
tag->mIntent = newIntent;
tv->SetTag(tag);
tv->SetVisibility(IView::VISIBLE);
tv->SetPressed(FALSE);
tv->ClearFocus();
++index;
}
}
//.........这里部分代码省略.........