2013年7月29日 星期一

startactivity (bring to top)

launchIntent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);

-----------------------------------------------------------------------------------
multitask

2013年7月28日 星期日

建立shortcut (註冊shortcut)


Shortcuts had existed since API level 1, and can be used by 3rd party apps as well.
To add an activity to the shortcuts manu simply add this intent filter to your activity in your manifest:
    <intent-filter>
        <action android:name="android.intent.action.CREATE_SHORTCUT" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
To make the activity plant a new icon with an intent on the home screen, do this before finishing:
Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent());
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "My shortcut");
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, myIcon);
setResult(RESULT_OK, intent);
Change the new Intent() to whatever you want launched when this is clicked.
share|improve this answer
----------------------------------------------------------------
As the error message suggests, you could add
android:exported="true"
to your activity.
Although this should be the default value if I read the android documentation right:
android:exported
Whether or not the activity can be launched by components of other applications — "true" if it can be, and "false" if not. If "false", the activity can be launched only by components of the same application or applications with the same user ID. The default value depends on whether the activity contains intent filters. The absence of any filters means that the activity can be invoked only by specifying its exact class name. This implies that the activity is intended only for application-internal use (since others would not know the class name). So in this case, the default value is "false". On the other hand, the presence of at least one filter implies that the activity is intended for external use, so the default value is "true".
Maybe someone else can clarify this.

2013年7月20日 星期六

中文化

// ----------------------------------中文化
          String localee = Locale.getDefault().getDisplayLanguage();
          if (localee.equals("中文")) {
               cb1.setText("1. 開啟Wifi ");
               cb2.setText("2. 關閉Wifi ");
               Locale locale = getBaseContext().getResources().getConfiguration().locale;
               String country = locale.getCountry(); //獲得國家碼
               if(country.equals("CN")){
                    cb1.setText("1. 开启Wifi ");               
                    cb2.setText("2. 关闭Wifi ");
               }
          }
          // ----------------------------------中文化end 
Related Posts Plugin for WordPress, Blogger...