
Intent intent= new Intent(IntentACTION_GET_CONTENT);
intentsetDataAndType(MediaStoreImagesMediaEXTERNAL_CONTENT_URI, "image/");
startActivityForResult(intent, REQUEST_CODE_SELECT_IMAGE);
表示调用相册选择
如果你要选择文件:
Intent intent= new Intent(IntentACTION_GET_CONTENT);
intentsetDataAndType(MediaStoreImagesMediaEXTERNAL_CONTENT_URI, "file/");
startActivityForResult(intent, REQUEST_CODE_SELECT_IMAGE);
1 IntentACTION_MAIN
String: AndroidintentactionMAIN标识Activity为一个程序的开始。比较常用。Input:nothingOutput:nothing
2 IntentAction_CALL
直接呼叫,在60之后的版本需要获取权限,详见 Android开发学习之路-Android60运行时权限转
Stirng: androidintentactionCALL呼叫指定的电话号码。Input:电话号码。数据格式为:tel:+phone number Output:Nothing
Intent intent=new Intent(); intentsetAction(IntentACTION_CALL);
intentsetData(Uriparse("tel:1320010001");
startActivity(intent);
3 IntentActionDIAL
String: actionintentactionDIAL调用拨号面板
Intent intent=new Intent();intentsetAction(IntentACTION_DIAL); //androidintentactionDIAL
intentsetData(Uriparse("tel:1320010001");
startActivity(intent);
Input:电话号码。数据格式为:tel:+phone number Output:Nothing说明:打开Android的拨号UI。如果没有设置数据,则打开一个空的UI,如果设置数据,actionDIAL则通过调用getData()获取电话号码。但设置电话号码的数据格式为 tel:+phone number
4 IntentActionALL_APPS
String: andriodintentactionALL_APPS列出所有的应用。Input:NothingOutput:Nothing
5IntentACTION_ANSWER
Stirng:androidintentactionANSWER处理呼入的电话。Input:NothingOutput:Nothing
6 IntentACTION_ATTACH_DATA
String: androidactionATTCH_DATA别用于指定一些数据应该附属于一些其他的地方,例如,数据应该附属于联系人Input: DataOutput:nothing
7 IntentACTION_BUG_REPORT
String: androidintentactionBUG_REPORT显示Dug报告。Input:nothingoutput:nothing
8 IntentAction_CALL_BUTTON
String: androidactionintentCALL_BUTTON相当于用户按下“拨号”键。经测试显示的是“通话记录”Input:nothingOutput:nothing
Intent intent = new Intent(IntentACTION_CALL_BUTTON);startActivity(intent);
9 IntentACTION_CHOOSER
String: androidintentactionCHOOSER显示一个activity选择器,允许用户在进程之前选择他们想要的,与之对应的是IntentACTION_GET_CONTENT
10 IntentACTION_GET_CONTENT
String: androidintentactionGET_CONTENT允许用户选择特殊种类的数据,并返回(特殊种类的数据:照一张相片或录一段音)
Input: TypeOutput:URI
int requestCode = 1001;Intent intent = new Intent(IntentACTION_GET_CONTENT); // "androidintentactionGET_CONTENT"
intentsetType("image/"); // 查看类型,如果是其他类型,比如视频则替换成 video/,或 /
Intent wrapperIntent = IntentcreateChooser(intent, null);startActivityForResult(wrapperIntent, requestCode);
11 IntentACTION_VIEW
String:androidintentactionVIEW用于显示用户的数据。比较通用,会根据用户的数据类型打开相应的Activity。比如 tel:13400010001打开拨号程序,>
Android系统中,判断应用是否首次安装,只能在服务器去判断,前台只能判断有无安装,判断有以下方式:
1根据包名判断,以下为判断代码:
public boolean checkApkExist(Context context, String packageName) {
if (packageName == null || “”equals(packageName))
return false;
try {
ApplicationInfo info = contextgetPackageManager()
getApplicationInfo(packageName,
PackageManagerGET_UNINSTALLED_PACKAGES);
return true;
} catch (NameNotFoundException e) {
return false;
}
}
2 根据Intent判断,以下为判断代码:
public boolean checkApkExist(Context context, Intent intent) {
List<ResolveInfo> list = contextgetPackageManager()queryIntentActivities(intent, 0);
if(listsize() > 0){
return true;
}
return false;
}
public boolean checkApkExist(Context context, String packageName) {
if (packageName == null || “”equals(packageName)) return false;
try {
ApplicationInfo info = contextgetPackageManager() getApplicationInfo(packageName, PackageManagerGET_UNINSTALLED_PACKAGES); return true;
} catch (NameNotFoundException e) { return false; }
}
public boolean checkApkExist(Context context, Intent intent) {
List<ResolveInfo> list = contextgetPackageManager()
queryIntentActivities(intent, 0);
if (listsize() > 0) {
return true;
}
return false;
}
你可以使用以下代码代替你的 ACTION_CALL(推荐):
Intent intent = new Intent(IntentACTION_DIAL);也可以参考这里,在 manifest 中添加
androidpermissionPHONE_CALL的权限,并且在拨打电话之前检验权限:
//检查是否已经给了权限int checkpermission= ContextCompatcheckSelfPermission(getApplicationContext(),ManifestpermissionACCESS_FINE_LOCATION);
if(checkpermission!=PackageManagerPERMISSION_GRANTED){ //没有给权限,申请
//参数分别是当前活动,权限字符串数组,requestcode
ActivityCompatrequestPermissions(MainActivitythis,new String[]{ManifestpermissionACCESS_FINE_LOCATION}, 1);
// 暂时使用 DIAL 代替 CALL
Intent intent = new Intent(IntentPHONE_DIAL);
intentsetData(Uriparse("tel:"+number));
startActivity(intent);
} else {
// 直接使用 CALL
Intent intent = new Intent(IntentPHONE_CALL);
intentsetData(Uriparse("tel:"+number));
startActivity(intent);
}
然后添加一个方法:
@Overridepublic void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
superonRequestPermissionsResult(requestCode, permissions, grantResults);
//grantResults数组与权限字符串数组对应,里面存放权限申请结果
if(grantResults[0]== PackageManagerPERMISSION_GRANTED){
// 放已授权的处理方法
}else{
// 放拒绝授权的处理方法
ToastmakeText(MainActivitythis,"拒绝授权",ToastLENGTH_SHORT)show();
}
}
参考:CSDN
1 IntentACTION_MAIN
String: androidintentactionMAIN
标识Activity为一个程序的开始。比较常用。
Input:nothing
Output:nothing
例如:
1
2
3
4
5
6
也可以直接在程序中实现 Intent it = new Intent(原Activityclass,需跳转Activityclass);
2 IntentAction_CALL
Stirng: androidintentactionCALL
呼叫指定的电话号码。
Input:电话号码。数据格式为:tel:+phone number
Output:Nothing
Intent intent=new Intent();
intentsetAction(IntentACTION_CALL);
intentsetData(Uriparse("tel:1320010001");
startActivity(intent);
3 IntentActionDIAL
String: actionintentactionDIAL
调用拨号面板
Intent intent=new Intent();
intentsetAction(IntentACTION_DIAL); //androidintentactionDIAL
intentsetData(Uriparse("tel:1320010001");
startActivity(intent);
Input:电话号码。数据格式为:tel:+phone number
Output:Nothing
说明:打开Android的拨号UI。如果没有设置数据,则打开一个空的UI,如果设置数据,actionDIAL则通过调用getData()获取电话号码。
但设置电话号码的数据格式为 tel:+phone number
4IntentActionALL_APPS
String: andriodintentactionALL_APPS
列出所有的应用。
Input:Nothing
Output:Nothing
5IntentACTION_ANSWER
Stirng:androidintentactionANSWER
处理呼入的电话。
Input:Nothing
Output:Nothing
6 IntentACTION_ATTACH_DATA
String: androidactionATTCH_DATA
别用于指定一些数据应该附属于一些其他的地方,例如,数据应该附属于联系人
Input: Data
Output:nothing
7 IntentACTION_BUG_REPORT
String: androidintentactionBUG_REPORT
显示Dug报告。
Input:nothing
output:nothing
8 IntentAction_CALL_BUTTON
String: androidactionintentCALL_BUTTON
相当于用户按下“拨号”键。经测试显示的是“通话记录”
Input:nothing
Output:nothing
Intent intent = new Intent(IntentACTION_CALL_BUTTON);
startActivity(intent);
9 IntentACTION_CHOOSER
String: androidintentactionCHOOSER
显示一个activity选择器,允许用户在进程之前选择他们想要的,与之对应的是IntentACTION_GET_CONTENT
10 IntentACTION_GET_CONTENT
String: androidintentactionGET_CONTENT
允许用户选择特殊种类的数据,并返回(特殊种类的数据:照一张相片或录一段音)
Input: Type
Output:URI
这个以前用到过,看事例。
选择一个:
代码
int requestCode = 1001;
Intent intent = new Intent(IntentACTION_GET_CONTENT); // "androidintentactionGET_CONTENT"
intentsetType("image/"); // 查看类型,如果是其他类型,比如视频则替换成 video/,或 /
Intent wrapperIntent = IntentcreateChooser(intent, null);
startActivityForResult(wrapperIntent, requestCode);
你的问题我理解的是从一张上。挖取指定坐标的一块是吧。
看代码的意思是。你想用参数的方法直接从camera取得。这种方法没有尝试过。
这一定得需要camera支持。识别extra里的参数。这样实际是调用系统的api处理
倒不如你换个方法。把这些图品剪切的动作放到本地里做。只从照片中取得整张。避免API不支持或版本不支持
以上就是关于怎么获取android系统服务,如Uri,intent参数等,或者说去哪里查看全部的内容,包括:怎么获取android系统服务,如Uri,intent参数等,或者说去哪里查看、android怎样缓存数据面试题、android中怎么读取系统相册等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)