當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。