zoukankan      html  css  js  c++  java
  • activityalias的使用

    activity-alias是android里为了重复使用Activity而设计的。

    当在Activity的onCreate()方法里,执行getIntent().getComponent().getClassName();得到的可能不是这个Activity的名字,有可能是别名的名字,例如:在AndroidMenifest.xml有如下配置:

     

    [xhtml] view plaincopy
    1. <activity   
    2.     android:name=".TestAndroid"  
    3.     android:icon="@drawable/ic_menu_mark">  
    4.         <intent-filter>  
    5.             <action android:name="android.intent.action.MAIN" />  
    6.             <category android:name="android.intent.category.LAUNCHER" />  
    7.         </intent-filter>  
    8. </activity>  

     

    [xhtml] view plaincopy
    1. <activity-alias   
    2.     android:name="TestAndroidAlias"  
    3.     android:targetActivity="TestAndroid"  
    4.     android:label="testAndroidlias"  
    5.     android:icon="@drawable/ic_launcher_phone">  
    6.         <intent-filter>  
    7.             <action android:name="android.intent.action.MAIN" />  
    8.             <category android:name="android.intent.category.DEFAULT" />  
    9.             <category android:name="android.intent.category.LAUNCHER" />  
    10.         </intent-filter>  
    11. </activity-alias>  

     

    这个应用会在桌面上建两个进入点,即建两个可以进入TestAndroid这个Activity的快捷图标。这时getIntent().getComponent().getClassName() 得到的名字就不一样,一个是com.test.TestAndroid,一个是com.test.TestAndroidAlias。

  • 相关阅读:
    vue-webpack介绍
    vue-ES6模块化的导入和导出
    vue-前端模块化
    vue-插槽作用域的使用
    vue-具名插槽的使用
    vue-插槽的基本使用
    vue-父组件获取子组件对象实例
    IO(六)
    IO(五)
    关于overflow:hidden
  • 原文地址:https://www.cnblogs.com/firecode/p/2854945.html
Copyright © 2011-2022 走看看