android批量
⑴ android可以批量移动、删除文件吗怎么操作
去下一个文件管理软件,比如“Winten文件管理器”,里面自带批量移动、删除文件功能
⑵ 安卓手机怎么批量删除照片
安卓手机可以按住想要删除的照片然后把需要删除的都勾选上这样就可以批量删除了。
⑶ 安卓手机怎么批量删除联系人 手机知道
1、在手机的屏幕上找到(设置)这个选项
⑷ 请问android裏面如何对id进行批量处理
把他们放在一个父容器里,比如一个LinearLayout parent
int childCount = parent.getChildCount();
for(int i=0;i<childCount;i++){
Button btn = (Button) parent.getChildAt(i);
**************************
}
⑸ android 如何优化ant 批量打包
1.配置java的环境变量
很多Java程序员由于使用Eclipse不配置Java环境变量也能正常运行代码。但是如果想使用Ant命令批量打包本步骤必不可少。
2. 下载Ant(这里的Ant不是eclipse和android SDk里面自带的ant)
3. 解压Ant并配置环境变量
a) 解压Ant,比如解压到D:\ant
b) 我的电脑->属性->高级->环境变量
c) 系统变量新建ANT_HOME,变量值为d:\ant
d) 系统变量新建或修改PATH:将%ANT_HOME%\bin;%ANT_HOME%\lib添加到环境变量的PATH中 (注意以上
路径均用反斜杠)
4. 验证ant配置是否正确
在控制台输入Cmd 回车, ant 回车,如果出现:
Buildfile: build.xml does not exist!
Build failed
恭喜你已经ant配置成功!!
Ant批量打包的基本思想是,每次打包后自动替换渠道号,然后再次打包从而实现多渠道打包的目的。
但是Ant不支持循环,怎样循环打包? 扩展包Ant-contrib能轻松解决这个问题.可以翻墙的1.0b3.jar放到Ant的lib文件夹即可.
5. 编写build.xml
将以下带有颜色的字体(包括路径,项目名称)都改成正确的名称
<?xml version="1.0" encoding="UTF-8"?>
<project name="ThumbPlay" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
unless="sdk.dir"
/>
<!-- extension targets. Uncomment the ones where you want to do custom work
in between standard targets -->
<!--
<target name="-pre-build">
</target>
<target name="-pre-compile">
</target>
<target name="-post-compile">
</target>
-->
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- /paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- /paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="D:/androidDev/batch-package-tool/ant1.8.3/lib/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<import file="${sdk.dir}/tools/ant/build.xml" />
<target name="deploy">
<foreach target="modify_manifest" list="${market_channels}" param="channel" delimiter=",">
</foreach>
</target>
<target name="modify_manifest">
<!--<replaceregexp file="AndroidManifest.xml" encoding="utf-8" match="android:value="(.*)"" replace=""/>-->
<replaceregexp flags="g" byline="false">
<regexp pattern="android:name="UMENG_CHANNEL" android:value="(.*)"" />
<substitution expression="android:name="UMENG_CHANNEL" android:value="${channel}"" />
<fileset dir="" includes="AndroidManifest.xml" />
</replaceregexp>
<!--<property name="out.release.file" value="${out.absolute.dir}/${channel}.apk"/>-->
<antcall target="release"/>
< tofile="${gos.path}/ThumbPlay_${channel}.apk">
<fileset dir="${out.absolute.dir}/" includes="ThumbPlay-release.apk" />
</>
<delete includeEmptyDirs="true">
<fileset dir="${out.absolute.dir}" includes="**/*"/>
</delete>
<echo message="==========================="/>
</target>
</project>
6. 配置local.properties
sdk.dir=D:\\androidDev\\android-sdk 改成你的SDK所在的目录,注意转义字符
7. 配置ant.properties
# the config file for batch package.
application.package=com.leyou.thumb (你的apk文件的包名)
ant.project.name=ThumbPlay (你的apk文件的工程名)
java.encoding=utf-8
out.absolute.dir=C:/compile
gos.path=Z:/app-version/test (打好的渠道包要放到的目的位置)
key.store=D:/androidApk/thumbplay/thumbplay.keystore (keystore文件路径)
key.store.password=wushenshiji999 (keystore文件路径)
key.alias=mugame (keystore文件别名)
key.alias.password=wushenshiji999 (keystore文件别名密码)
app_version=1.0.4 (要打的渠道包的版本名称)
market_channels=guanwang,shuihu,wushen,shenhua,huawei (渠道名称,要以逗号分隔,必须在一行内)
⑹ android 怎么批量插入联系人,高效率的方法
参考下面:
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
ArrayList<VCardEntry> list = params[0];
Iterator<VCardEntry> it = null;
if (list != null) {
it = list.iterator();
}
Logger.v(TAG,"--->doInBackground it:"+it);
int rawContactInsertIndex = 0;
while(it!= null && it.hasNext()) {
VCardEntry mv = it.next();
rawContactInsertIndex = ops.size(); // 有了它才能给真正的实现批量添加
Logger.v(TAG,"--->>>>>>>name:"+mv.getDisplayName());
Logger.v(TAG,"--->>>>>>>getPhoneList:"+mv.getPhoneList());
if (mv.getPhoneList() != null) {
ops.add(ContentProviderOperation
.newInsert(RawContacts.CONTENT_URI)
.withValue(RawContacts.ACCOUNT_TYPE, ACCOUNT_NAME)
.withValue(RawContacts.ACCOUNT_NAME, ACCOUNT_TYPE)
.withYieldAllowed(true).build());
// add name
ops.add(ContentProviderOperation
.newInsert(Data.CONTENT_URI)
.withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex)
.withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
.withValue(StructuredName.DISPLAY_NAME, mv.getDisplayName())
.withYieldAllowed(true).build());
// add number
for(VCardEntry.PhoneData phone : mv.getPhoneList()) {
Logger.v(TAG,"--->>>>>>>number:"+phone.getNumber());
ops.add(ContentProviderOperation
.newInsert(Data.CONTENT_URI)
.withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex)
.withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE)
.withValue(Phone.NUMBER, phone.getNumber())
.withValue(Phone.TYPE, Phone.TYPE_MOBILE)
.withValue(Phone.LABEL, "")
.withYieldAllowed(true).build());
}
}
}
ContentProviderResult[] results = null;
if (ops != null) {
try {
results = mContext.getContentResolver()
.applyBatch(ContactsContract.AUTHORITY, ops);
} catch (RemoteException e) {
Logger.e(TAG,String.format("%s: %s", e.toString(), e.getMessage()));
} catch (OperationApplicationException e) {
Logger.e(TAG,String.format("%s: %s", e.toString(), e.getMessage()));
}
}
⑺ android如何实现图片批量上传
首先,以下架构下的批量文件上传可能会失败或者不会成功:
1.android客户端+springMVC服务端:服务端采用org.springframework.web.multipart.MultipartHttpServletRequest作为批量上传接收类,这种搭配下的批量文件上传会失败,最终服务端只会接受到一个文件,即只会接受到第一个文件。可能因为MultipartHttpServletRequest对servlet原本的HttpServletRequest类进行封装,导致批量上传有问题。
2.android客户端+strutsMVC服务端:
上传成功的方案:
采用android客户端+Servlet(HttpServletRequest)进行文件上传。
Servlet端代码如下:
[java] view plainprint?
DiskFileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
try
{
List items = upload.parseRequest(request);
Iterator itr = items.iterator();
while (itr.hasNext())
{
FileItem item = (FileItem) itr.next();
if (item.isFormField())
{
System.out.println("表单参数名:" + item.getFieldName() + ",表单参数值:" + item.getString("UTF-8"));
}
else
{
if (item.getName() != null && !item.getName().equals(""))
{
System.out.println("上传文件的大小:" + item.getSize());
System.out.println("上传文件的类型:" + item.getContentType());
// item.getName()返回上传文件在客户端的完整路径名称
System.out.println("上传文件的名称:" + item.getName());
File tempFile = new File(item.getName());
// 上传文件的保存路径
File file = new File(sc.getRealPath("/") + savePath, tempFile.getName());
item.write(file);
request.setAttribute("upload.message", "上传文件成功!");
} else
{
request.setAttribute("upload.message", "没有选择上传文件!");
}
}
}
}
catch (FileUploadException e)
{
e.printStackTrace();
}
catch (Exception e)
{
e.printStackTrace();
request.setAttribute("upload.message", "上传文件失败!");
}
request.getRequestDispatcher("/uploadResult.jsp").forward(request, response);
android端代码如下:
[java] view plainprint?
public class SocketHttpRequester {
/**
*多文件上传
* 直接通过HTTP协议提交数据到服务器,实现如下面表单提交功能:
* <FORM METHOD=POST ACTION="http://192.168.1.101:8083/upload/servlet/UploadServlet" enctype="multipart/form-data">
<INPUT TYPE="text" NAME="name">
<INPUT TYPE="text" NAME="id">
<input type="file" name="imagefile"/>
<input type="file" name="zip"/>
</FORM>
* @param path 上传路径(注:避免使用localhost或127.0.0.1这样的路径测试,因为它会指向手机模拟器,你可以使用http://www.iteye.cn或http://192.168.1.101:8083这样的路径测试)
* @param params 请求参数 key为参数名,value为参数值
* @param file 上传文件
*/
public static boolean post(String path, Map<String, String> params, FormFile[] files) throws Exception{
final String BOUNDARY = "---------------------------7da2137580612"; //数据分隔线
final String endline = "--" + BOUNDARY + "--\r\n";//数据结束标志
int fileDataLength = 0;
for(FormFile uploadFile : files){//得到文件类型数据的总长度
StringBuilder fileExplain = new StringBuilder();
fileExplain.append("--");
fileExplain.append(BOUNDARY);
fileExplain.append("\r\n");
fileExplain.append("Content-Disposition: form-data;name=\""+ uploadFile.getParameterName()+"\";filename=\""+ uploadFile.getFilname() + "\"\r\n");
fileExplain.append("Content-Type: "+ uploadFile.getContentType()+"\r\n\r\n");
fileExplain.append("\r\n");
fileDataLength += fileExplain.length();
if(uploadFile.getInStream()!=null){
fileDataLength += uploadFile.getFile().length();
}else{
fileDataLength += uploadFile.getData().length;
}
}
StringBuilder textEntity = new StringBuilder();
for (Map.Entry<String, String> entry : params.entrySet()) {//构造文本类型参数的实体数据
textEntity.append("--");
textEntity.append(BOUNDARY);
textEntity.append("\r\n");
textEntity.append("Content-Disposition: form-data; name=\""+ entry.getKey() + "\"\r\n\r\n");
textEntity.append(entry.getValue());
textEntity.append("\r\n");
}
//计算传输给服务器的实体数据总长度
int dataLength = textEntity.toString().getBytes().length + fileDataLength + endline.getBytes().length;
URL url = new URL(path);
int port = url.getPort()==-1 ? 80 : url.getPort();
Socket socket = new Socket(InetAddress.getByName(url.getHost()), port);
OutputStream outStream = socket.getOutputStream();
//下面完成HTTP请求头的发送
String requestmethod = "POST "+ url.getPath()+" HTTP/1.1\r\n";
outStream.write(requestmethod.getBytes());
String accept = "Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*\r\n";
outStream.write(accept.getBytes());
String language = "Accept-Language: zh-CN\r\n";
outStream.write(language.getBytes());
String contenttype = "Content-Type: multipart/form-data; boundary="+ BOUNDARY+ "\r\n";
outStream.write(contenttype.getBytes());
String contentlength = "Content-Length: "+ dataLength + "\r\n";
outStream.write(contentlength.getBytes());
String alive = "Connection: Keep-Alive\r\n";
outStream.write(alive.getBytes());
String host = "Host: "+ url.getHost() +":"+ port +"\r\n";
outStream.write(host.getBytes());
//写完HTTP请求头后根据HTTP协议再写一个回车换行
outStream.write("\r\n".getBytes());
//把所有文本类型的实体数据发送出来
outStream.write(textEntity.toString().getBytes());
//把所有文件类型的实体数据发送出来
for(FormFile uploadFile : files){
StringBuilder fileEntity = new StringBuilder();
fileEntity.append("--");
fileEntity.append(BOUNDARY);
fileEntity.append("\r\n");
fileEntity.append("Content-Disposition: form-data;name=\""+ uploadFile.getParameterName()+"\";filename=\""+ uploadFile.getFilname() + "\"\r\n");
fileEntity.append("Content-Type: "+ uploadFile.getContentType()+"\r\n\r\n");
outStream.write(fileEntity.toString().getBytes());
if(uploadFile.getInStream()!=null){
byte[] buffer = new byte[1024];
int len = 0;
while((len = uploadFile.getInStream().read(buffer, 0, 1024))!=-1){
outStream.write(buffer, 0, len);
}
uploadFile.getInStream().close();
}else{
outStream.write(uploadFile.getData(), 0, uploadFile.getData().length);
}
outStream.write("\r\n".getBytes());
}
//下面发送数据结束标志,表示数据已经结束
outStream.write(endline.getBytes());
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
if(reader.readLine().indexOf("200")==-1){//读取web服务器返回的数据,判断请求码是否为200,如果不是200,代表请求失败
return false;
}
outStream.flush();
outStream.close();
reader.close();
socket.close();
return true;
}
/**
*单文件上传
* 提交数据到服务器
* @param path 上传路径(注:避免使用localhost或127.0.0.1这样的路径测试,因为它会指向手机模拟器,你可以使用http://www.itcast.cn或http://192.168.1.10:8080这样的路径测试)
* @param params 请求参数 key为参数名,value为参数值
* @param file 上传文件
*/
public static boolean post(String path, Map<String, String> params, FormFile file) throws Exception{
return post(path, params, new FormFile[]{file});
}
}
⑻ 如何在安卓手机上批量重命名文件啊
先下载 文件管理器,可以在网络应用里面搜索,安装完成。
打开 SD 卡,选择要重命名的文件。(以常见的 MP3文件举例)
按住一个文件不放手,直至进入多选状态,把要重命名的文件都先选上。
点击最下面的选项,重命名。
以一定的名称按序号重命名文件,我们原来的文件上1.mp3……5.mp3
为了方便管理,我举例把它们改为 歌曲1.mp3……歌曲5.mp3,因为播放器在升降排序的时候,不会按照数字大小排列,而是按照开头数字大小.
如下图操作,点击确定,就会完成如图。
最后还有 两种批量重命名,操作方法雷同,给大家看下结果
1,新文件名+旧文件名
2,批量改掉扩展名
把两种重命名方法同时使用举例,要把以上的文件重命名为扩展名为 .mp4的文件,因此文件开头不能是歌曲了,应该改成视频歌曲,把这两种方法都使用了一遍
⑼ Android 可以用代码实现批量删除某一类型文件吗 比如rm /sdcard/*.mp4*
当然可以了,可以使用File对象的delete方法删除,如果不用这个方法,也可以使用Runtime.getRuntime().exec("rm
file");但前提是你的android系统的底层内核包含rm命令.你可以使用adb
shell,查看system/bin,system/xbin等文件夹中,如果其中包含rm那就可以;另外这个应用需要root权限,还有就是rm在命令行使用的时候就加上强制删除参数,即"rm
-rf"
⑽ android 怎么批量调用百度地图的地理编码功能
一、下载最新网络地图sdk,导入工程中
二、根据官方文档初始化地图,在main.xml中添加对应布局
<com..mapapi.map.MapView
android:id="@+id/bmapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"/>
//获取地图控件引用
mapView = (MapView) findViewById(R.id.bmapView);
Map = mapView.getMap(); // 获取地图控制器
三、通过地理编码获取经纬度
p//第一步,创建地理编码检索实例;
mSearch=GeoCoder.newInstance();//第二步,创建地理编码检索监听者;
=(){publicvoidonGetGeoCodeResult(GeoCodeResultresult){if(result==null||result.error!=SearchResult.ERRORNO.NO_ERROR){//没有检索到结果
}else{//获取地理编码结果
floatlatitude=(float)result.getLocation().latitude;floatlongitude=(float)result.getLocation().longitude;finalLatLngpoint=newLatLng(latitude,longitude);//加载自定义marker
ViewpopMarker=View.inflate(MainActivity.this,R.layout.pop,null);
Bitmapbitmap1=getViewBitmap(popMarker);
=BitmapDescriptorFactory.fromBitmap(bitmap1);//构建MarkerOption,用于在地图上添加Marker
OverlayOptionsoption=newMarkerOptions()
.position(point)
.icon(bitmapDescriptor);//在地图上添加Marker,并显示
Markermarker=(Marker)Map.addOverlay(option);
}
}@Override
(ReverseGeoCodeResultresult){if(result==null||result.error!=SearchResult.ERRORNO.NO_ERROR){//没有找到检索结果
}//获取反向地理编码结果
}
};//第三步,设置地理编码检索监听者;
mSearch.setOnGetGeoCodeResultListener(listener);//第四步,发起地理编码检索;
mSearch.geocode(newGeoCodeOption()
.city("北京")
.address("海淀区上地十街10号"));//网络地图上少一个括号
将View转换成Bitmap的方法/**
*将View转换成Bitmap
*@paramaddViewContent
*@return
*/privateBitmapgetViewBitmap(ViewaddViewContent){
addViewContent.setDrawingCacheEnabled(true);
addViewContent.measure(
View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED),
View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED));
addViewContent.layout(0,0,
addViewContent.getMeasuredWidth(),
addViewContent.getMeasuredHeight());
addViewContent.buildDrawingCache();
BitmapcacheBitmap=addViewContent.getDrawingCache();
Bitmapbitmap=Bitmap.createBitmap(cacheBitmap);returnbitmap;
}
Marker的自定义布局pop.xml
<?xmlversion="1.0"encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<ImageView
android:id="@+id/iv_title"
android:layout_width="42dp"
android:layout_height="42dp"
/>
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="42dp"
android:padding="5dp"
android:gravity="center"
android:text="标题"
android:textSize="16dp"/></LinearLayout>