当前位置: 首页>>代码示例>>Java>>正文


Java ComponentName.flattenToShortString方法代码示例

本文整理汇总了Java中android.content.ComponentName.flattenToShortString方法的典型用法代码示例。如果您正苦于以下问题:Java ComponentName.flattenToShortString方法的具体用法?Java ComponentName.flattenToShortString怎么用?Java ComponentName.flattenToShortString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.ComponentName的用法示例。


在下文中一共展示了ComponentName.flattenToShortString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getActivityIconWithCache

import android.content.ComponentName; //导入方法依赖的package包/类
/**
 * Gets the activity or application icon for an activity.
 * Uses the local icon cache for fast repeated lookups.
 *
 * @param component Name of an activity.
 * @return A drawable, or {@code null} if neither the activity nor the application
 *         has an icon set.
 */
private Drawable getActivityIconWithCache(ComponentName component) {
    // First check the icon cache
    String componentIconKey = component.flattenToShortString();
    // Using containsKey() since we also store null values.
    if (mOutsideDrawablesCache.containsKey(componentIconKey)) {
        Drawable.ConstantState cached = mOutsideDrawablesCache.get(componentIconKey);
        return cached == null ? null : cached.newDrawable(mProviderContext.getResources());
    }
    // Then try the activity or application icon
    Drawable drawable = getActivityIcon(component);
    // Stick it in the cache so we don't do this lookup again.
    Drawable.ConstantState toCache = drawable == null ? null : drawable.getConstantState();
    mOutsideDrawablesCache.put(componentIconKey, toCache);
    return drawable;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:24,代码来源:SuggestionsAdapter.java

示例2: getCurrentActivityName

import android.content.ComponentName; //导入方法依赖的package包/类
private void getCurrentActivityName(AccessibilityEvent event) {
    if (event.getEventType() != AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
        return;
    }
    try {
        String pkgName = event.getPackageName().toString();
        String className = event.getClassName().toString();
        ComponentName componentName = new ComponentName(pkgName, className);
        getPackageManager().getActivityInfo(componentName, 0);
        currentActivityName = componentName.flattenToShortString();
        Log.d("MyService", "cur=" + currentActivityName);
        if(sp.getBoolean("notification_switch",false)){
            NotificationUtils.updateNotification(this,currentActivityName);
        }
    } catch (PackageManager.NameNotFoundException e) {
        //只是窗口变化,并无activity调转
        Log.d("MyService", "e=" + e.getLocalizedMessage());
    }
}
 
开发者ID:paozhuanyinyu,项目名称:FreshMember,代码行数:20,代码来源:MyService.java

示例3: setCurrentActivityName

import android.content.ComponentName; //导入方法依赖的package包/类
private void setCurrentActivityName(AccessibilityEvent event) {
    if (event.getEventType() != AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
        return;
    }

    try {
        ComponentName componentName = new ComponentName(
                event.getPackageName().toString(),
                event.getClassName().toString()
        );

        getPackageManager().getActivityInfo(componentName, 0);
        currentActivityName = componentName.flattenToShortString();
    } catch (PackageManager.NameNotFoundException e) {
        currentActivityName = WECHAT_LUCKMONEY_GENERAL_ACTIVITY;
    }
}
 
开发者ID:KoreHuang,项目名称:WeChatLuckyMoney,代码行数:18,代码来源:HongbaoService.java

示例4: checkOpenActivity

import android.content.ComponentName; //导入方法依赖的package包/类
private void checkOpenActivity(int viewId, String nextActivity)
{
    ActivityController controller = startWithProperty(new Property());
    Activity activity = (Activity)controller.get();

    View propertyView = activity.findViewById(viewId);
    propertyView.performClick();

    assertTrue(activity.isFinishing() == false);
    Intent next = shadowOf(activity).getNextStartedActivity();

    ComponentName componentName = next.getComponent();
    String name = componentName.flattenToShortString();
    assertEquals(nextActivity, name);

    Bundle extras = next.getExtras();
    assertNotNull(extras);
    assertTrue(extras.containsKey("id"));
    long id = extras.getLong("id", -1);
    assertEquals(DatabaseTestHelper.FIRST_ID, id);
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:22,代码来源:PropertyOverviewActivityTest.java

示例5: clickAddLaunchesActivity

import android.content.ComponentName; //导入方法依赖的package包/类
@Test
public void clickAddLaunchesActivity()
{
    ActivityController controller = Robolectric.buildActivity(PropertiesListActivity.class).create();
    Activity activity = (Activity)controller.get();

    controller.start();
    controller.visible();
    controller.resume();

    shadowOf(activity).clickMenuItem(R.id.action_add);
    assertTrue(activity.isFinishing() == false);

    Intent next = shadowOf(activity).getNextStartedActivity();

    ComponentName componentName = next.getComponent();
    String name = componentName.flattenToShortString();
    assertEquals("protect.rentalcalc/.PropertyViewActivity", name);

    Bundle extras = next.getExtras();
    assertNull(extras);
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:23,代码来源:PropertiesListActivityTest.java

示例6: testFirstRunStartsIntro

import android.content.ComponentName; //导入方法依赖的package包/类
@Test
public void testFirstRunStartsIntro()
{
    prefs.edit().remove("firstrun").commit();

    ActivityController controller = Robolectric.buildActivity(PropertiesListActivity.class).create();
    Activity activity = (Activity)controller.get();

    assertTrue(activity.isFinishing() == false);

    Intent next = shadowOf(activity).getNextStartedActivity();

    ComponentName componentName = next.getComponent();
    String name = componentName.flattenToShortString();
    assertEquals("protect.rentalcalc/.IntroActivity", name);

    Bundle extras = next.getExtras();
    assertNull(extras);

    assertEquals(false, prefs.getBoolean("firstrun", true));
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:22,代码来源:PropertiesListActivityTest.java

示例7: checkOpenActivity

import android.content.ComponentName; //导入方法依赖的package包/类
private void checkOpenActivity(ActivityController controller, int viewId, HashMap<String, Integer> items)
{
    Activity activity = (Activity)controller.get();
    activity.findViewById(viewId).performClick();

    assertTrue(activity.isFinishing() == false);

    ShadowActivity.IntentForResult next = shadowOf(activity).getNextStartedActivityForResult();

    ComponentName componentName = next.intent.getComponent();
    String name = componentName.flattenToShortString();
    assertEquals("protect.rentalcalc/.ItemizeActivity", name);

    Bundle extras = next.intent.getExtras();
    assertNotNull(extras);
    assertTrue(extras.containsKey("title"));
    assertTrue(extras.getInt("title") > 0);
    assertTrue(extras.containsKey("description"));
    assertTrue(extras.getInt("description") > 0);
    assertTrue(extras.containsKey("items"));
    assertEquals(items, extras.getSerializable("items"));

    // As the next activity is started, this activity is paused
    controller.pause();
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:26,代码来源:PropertyWorksheetActivityTest.java

示例8: setCurrentActivityName

import android.content.ComponentName; //导入方法依赖的package包/类
private void setCurrentActivityName(AccessibilityEvent event) {
    if (event.getEventType() != AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) return;
    try {
        ComponentName componentName = new ComponentName(event.getPackageName().toString(), event.getClassName().toString());
        getPackageManager().getActivityInfo(componentName, 0);
        currentActivityName = componentName.flattenToShortString();
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
}
 
开发者ID:WanAndroid,项目名称:GetRedPackets,代码行数:11,代码来源:WXRedPluginService.java

示例9: getActivityIconWithCache

import android.content.ComponentName; //导入方法依赖的package包/类
private Drawable getActivityIconWithCache(ComponentName component) {
    String componentIconKey = component.flattenToShortString();
    if (this.mOutsideDrawablesCache.containsKey(componentIconKey)) {
        ConstantState cached = (ConstantState) this.mOutsideDrawablesCache.get(componentIconKey);
        if (cached == null) {
            return null;
        }
        return cached.newDrawable(this.mProviderContext.getResources());
    }
    Drawable drawable = getActivityIcon(component);
    this.mOutsideDrawablesCache.put(componentIconKey, drawable == null ? null : drawable.getConstantState());
    return drawable;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:SuggestionsAdapter.java

示例10: clickPropertyLaunchesActivity

import android.content.ComponentName; //导入方法依赖的package包/类
@Test
public void clickPropertyLaunchesActivity()
{
    db.insertProperty(new Property());
    ActivityController controller = Robolectric.buildActivity(PropertiesListActivity.class).create();
    Activity activity = (Activity)controller.get();

    controller.start();
    controller.visible();
    controller.resume();

    ListView list = (ListView)activity.findViewById(R.id.list);
    ShadowListView shadowList = shadowOf(list);

    shadowList.populateItems();

    assertEquals(1, list.getCount());
    shadowList.performItemClick(0);

    assertTrue(activity.isFinishing() == false);

    Intent next = shadowOf(activity).getNextStartedActivity();

    ComponentName componentName = next.getComponent();
    String name = componentName.flattenToShortString();
    assertEquals("protect.rentalcalc/.PropertyOverviewActivity", name);

    Bundle extras = next.getExtras();
    assertNotNull(extras);
    assertTrue(extras.containsKey("id"));
    assertEquals(DatabaseTestHelper.FIRST_ID, extras.getLong("id"));
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:33,代码来源:PropertiesListActivityTest.java

示例11: startWithoutPropertyAndSave

import android.content.ComponentName; //导入方法依赖的package包/类
@Test
public void startWithoutPropertyAndSave() throws IllegalAccessException
{
    Intent intent = new Intent();
    final Bundle bundle = new Bundle();
    intent.putExtras(bundle);

    ActivityController controller = Robolectric.buildActivity(PropertyViewActivity.class, intent).create();
    Activity activity = (Activity)controller.get();
    controller.start();
    controller.visible();
    controller.resume();

    Property property = new Property();
    preloadProperty(property);
    setFields(activity, property);

    assertNotNull(shadowOf(activity).getOptionsMenu().findItem(R.id.action_save));
    shadowOf(activity).clickMenuItem(R.id.action_save);
    assertTrue(activity.isFinishing());

    Intent next = shadowOf(activity).getNextStartedActivity();
    ComponentName componentName = next.getComponent();
    String name = componentName.flattenToShortString();
    assertEquals("protect.rentalcalc/.PropertyOverviewActivity", name);
    Bundle nextBundle = next.getExtras();
    assertNotNull(nextBundle);
    assertTrue(nextBundle.containsKey("id"));
    assertEquals(DatabaseTestHelper.FIRST_ID, nextBundle.getLong("id"));

    Property updatedProperty = db.getProperty(DatabaseTestHelper.FIRST_ID);

    compareRelevantPropertyFields(property, updatedProperty);
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:35,代码来源:PropertyViewActivityTest.java


注:本文中的android.content.ComponentName.flattenToShortString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。