sit(a,"action","android.intent.action.GET_CONTENT")
sit(a,"settype")
sit(a,"type", "a/a")
uit(a,"result",1)
//回调事件
sj(st_iT,null,"//",jq1)
ss(jq1+"//",jq1)
sr(st_iT,jq1,"",st_iT)
sj(st_iT,null,"/",jq2)
ss(jq2+"/",jq2)
sr(st_iT,jq2,"",st_iT)
f(st_iT ? "typ=file/*")
{
芦裂 sj(st_iT,"咐哗稿typ=file/*",null,del)
ss("衡孝typ=file/*"+del,del)
sr(st_iT,del,"",st_iT)
syso(st_iT)
}
else f(st_iT ? "flg=")
{
sj(st_iT,"flg=",null,del)
ss("flg="+del,del)
sr(st_iT,del,"",st_iT)
syso(st_iT)
}
us(2,"text",st_iT)
//2为文本id
iapp 调用图库选择图片javags(agc,"android.content.Intent","android.content.Intent.ACTION_GET_CONTENT")
javanew(it,"android.content.Intent","String",agc)
java(c,it,"android.content.Intent.setType","String","image/*")
javags(ca,"android.content.Intent","android.content.Intent.CATEGORY_OPENABLE")
java(c,it,"android.content.Intent.addCategory","String",ca)
java(c,activity,"android.app.Activity.startActivityForResult","android.content.Intent"州信厅,it,"int",2)
回调事件javags(er,activity,"android.app.Activity","RESULT_OK")
f(st_lC==er)
{
f(st_sC==2)
{
java(uri,st_iT,"android.content.Intent.getData")
call(path, "mjava", "uri.getRealPath", activity, uri)
fdir(a)
ss(a+"/",a)
sr(path,a,"%",path)
us(控件id,"src",path)
}
}
uri.mjava
import android.content.ContentUris
import android.content.Intent
import android.net.Uri
import android.provider.DocumentsContract
import android.provider.MediaStore
import android.database.Cursor
import android.content.Context
public static String getRealPath(Context context, Uri uri)
{
String imagePath = null
if(DocumentsContract.isDocumentUri(context, uri))
{ 册隐
String docId = DocumentsContract.getDocumentId(uri)
if ("com.android.providers.media.documents".equals(uri.getAuthority())) 坦芦
{
String id = docId.split(":")[1]
String selection = MediaStore.Images.Media._ID + "=" + id
imagePath = getImagePath(context, MediaStore.Images.Media.EXTERNAL_CONTENT_URI, selection)
}
else if ("com.android.providers.downloads.documents".equals(uri.getAuthority()))
{
Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(docId))
imagePath = getImagePath(context, contentUri, null)
}
}
else if("content".equalsIgnoreCase(uri.getScheme()))
{
imagePath = getImagePath(context, uri, null)
}
else if("file".equalsIgnoreCase(uri.getScheme()))
{
imagePath = uri.getPath()
}
return imagePath
}
public String getImagePath(Context context, Uri uri, String selection)
{
String path = null
Cursor cursor = context.getContentResolver().query(uri, null, selection, null, null)
if (cursor != null)
{
if (cursor.moveToFirst())
{
path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA))
}
cursor.close()
}
return path
}
我们可以在过程中输入想要调用的函数。当我们输入一个括号后,我们就可以观察他的参数。我们在对应的参数中输羡耐好入参数值。我们会发现系统发生了一个警告。反正需要调用它相应的头文件。我们可以再次编译,亩森我不会发兄铅现没有任何警告和错误。欢迎分享,转载请注明来源:内存溢出
评论列表(0条)