1.从resources 里面的数组转化成代码:
int indicesInt[] = context.getResources().getIntArray(R.array.indices);
short indices[] = new short[indicesInt.length];
for (int i = 0; i < indicesInt.length; i++) { indices[i] = (short)indicesInt[i];}
2.intent-filter的用法,得到特定的网址后 自动响应intent
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:host="www.youtube.com" android:scheme="http"></data>
</intent-filter>
<uses-permission android:name="android.permission.INTERNET" />
<activity android:name=".activity.ExeReceiver">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:host=".*" />
<data android:mimeType="*/*"/>
</intent-filter>
</activity>
3. 得到后台运行的程序
ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> l = am.getRunningAppProcesses();
4.为程序添加一个“分享”发送到某个地方,只能在主xml实现目前,而不能用代码实现:
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter >
然后就可以启动代码了
Intent intent = new Intent(Intent.ACTION_SEND);
startActivity(Intent.createChooser(intent , "Send options"));
http://groups.google.com/group/android-developers/browse_thread/thread/62a514363c751464/feecc033d0265606?lnk=gst&q=intentfilter+share#feecc033d0265606
5.在代码中注册一个registerReceiver的方法:
public class MyActivity extends Activity {
private static final String TAG = "MyActivity";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_SEND);
intentFilter.addCategory(Intent.CATEGORY_DEFAULT);
try {
intentFilter.addDataType("image/*");
} catch (MalformedMimeTypeException e) {
Log.e(TAG, e.toString());
}
Intent x = registerReceiver(new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "Received intent "+intent);
intent.setComponent(new ComponentName(context,
Uploader.class));
startActivity(intent);
}
}, intentFilter);
if (x==null)
Log.i(TAG, "failed to regist a receiver");
else
Log.i(TAG, "registed a receiver successfully");
// ...
http://groups.google.com/group/android-developers/browse_thread/thread/ca183e0cbe0e1aec/34fa612bafd4c22f?lnk=gst&q=gallery#34fa612bafd4c22f
6.从CalendarProvider得到数据的方法:
ContentResolver contentResolver = context.getContentResolver();
Cursor cursor = contentResolver.query(Uri.parse("content://calendar/events"), null, null, null, null);
while(cursor.moveToNext()) {
String eventTitle = cursor.getString(cursor.getColumnIndex("title"));
Date eventStart = new Date(cursor.getLong(cursor.getColumnIndex("dtstart"))); // etc.}
让手机打不出电话解决办法
1) Create a BroadcastReceiver with a priority of 0. 2) In the BC intercept the ACTION_NEW_OUTGOING_CALL intent in its OnReceive method 3) call setResultData(null) in the same method
添加 an image icon in在expandable list view ,取代默认的图片
setGroupIndicator(Drawable)
int indicesInt[] = context.getResources().getIntArray(R.array.indices);
short indices[] = new short[indicesInt.length];
for (int i = 0; i < indicesInt.length; i++) { indices[i] = (short)indicesInt[i];}
2.intent-filter的用法,得到特定的网址后 自动响应intent
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:host="www.youtube.com" android:scheme="http"></data>
</intent-filter>
<uses-permission android:name="android.permission.INTERNET" />
<activity android:name=".activity.ExeReceiver">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:host=".*" />
<data android:mimeType="*/*"/>
</intent-filter>
</activity>
3. 得到后台运行的程序
ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> l = am.getRunningAppProcesses();
4.为程序添加一个“分享”发送到某个地方,只能在主xml实现目前,而不能用代码实现:
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter >
然后就可以启动代码了
Intent intent = new Intent(Intent.ACTION_SEND);
startActivity(Intent.createChooser(intent , "Send options"));
http://groups.google.com/group/android-developers/browse_thread/thread/62a514363c751464/feecc033d0265606?lnk=gst&q=intentfilter+share#feecc033d0265606
5.在代码中注册一个registerReceiver的方法:
public class MyActivity extends Activity {
private static final String TAG = "MyActivity";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_SEND);
intentFilter.addCategory(Intent.CATEGORY_DEFAULT);
try {
intentFilter.addDataType("image/*");
} catch (MalformedMimeTypeException e) {
Log.e(TAG, e.toString());
}
Intent x = registerReceiver(new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "Received intent "+intent);
intent.setComponent(new ComponentName(context,
Uploader.class));
startActivity(intent);
}
}, intentFilter);
if (x==null)
Log.i(TAG, "failed to regist a receiver");
else
Log.i(TAG, "registed a receiver successfully");
// ...
http://groups.google.com/group/android-developers/browse_thread/thread/ca183e0cbe0e1aec/34fa612bafd4c22f?lnk=gst&q=gallery#34fa612bafd4c22f
6.从CalendarProvider得到数据的方法:
ContentResolver contentResolver = context.getContentResolver();
Cursor cursor = contentResolver.query(Uri.parse("content://calendar/events"), null, null, null, null);
while(cursor.moveToNext()) {
String eventTitle = cursor.getString(cursor.getColumnIndex("title"));
Date eventStart = new Date(cursor.getLong(cursor.getColumnIndex("dtstart"))); // etc.}
让手机打不出电话解决办法
1) Create a BroadcastReceiver with a priority of 0. 2) In the BC intercept the ACTION_NEW_OUTGOING_CALL intent in its OnReceive method 3) call setResultData(null) in the same method
添加 an image icon in在expandable list view ,取代默认的图片
setGroupIndicator(Drawable)