首页 文章 精选 留言 我的

精选列表

搜索[安卓设备管理],共8303篇文章
优秀的个人博客,低调大师

jenkins 打包

环境准备 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 找一个台新机器,因为要升级内核文件,我升级,中文全部识别不了,全是乱码,没解决 yum - yinstallgccgcc - c + + autoconfautomake yuminstallglibc - common 解决libc.so. 6 :version`GLIBC_2. 14 ' not found问题 http: / / stuart.blog. 51cto .com / 728677 / 1840205 http: / / blog.csdn.net / cpplang / article / details / 8462768 curlhttp: / / dl.google.com / android / ndk / android - ndk - r10e - linux - x86_64. bin - - output / usr / java / android - ndk - r10e - linux - x86_64. bin android list sdk - u http: / / www.cnblogs.com / sink_cup / archive / 2011 / 12 / 01 / 2230344.html Ubuntu 15.10 x64安装AndroidSDK / usr / java / androidsdk / tools / bin sdkmanager "build-tools;25.0.0" / usr / java / androidsdk / platform - tools buildscript{ repositories{ jcenter() } dependencies{ classpath 'com.android.tools.build:gradle:2.3.1' } } http: / / blog.csdn.net / CheNorton / article / details / 50345039 工作环境搭建( 9 ) - CentOS7命令行安装AndroidNDK http: / / blog.csdn.net / CheNorton / article / details / 50353036 工作环境搭建( 8 ) - CentOS7命令行安装AndroidSDK http: / / blog.csdn.net / chenorton / article / details / 50345039 centos7中安装AndroidSDK的方法步骤 http: / / www.jb51.net / article / 119183.htm cat / etc / profile exportJAVA_HOME = / usr / java / jdk exportJRE_HOME = / usr / java / jdk / jre exportCLASSPATH = .:$JAVA_HOME / lib / dt.jar:$JAVA_HOME / lib / tools.jar:$JRE_HOME / lib exportPATH = $JAVA_HOME / bin :$PATH exportANDROID_SDK_HOME = / usr / java / android - sdk - linux exportANDROID_HOME = / usr / java / android - sdk - linux exportGRADLE_HOME = / usr / java / gradle - 3.3 exportMAVEN_HOME = / usr / java / apache - maven - 3.3 . 9 exportPATH = / usr / local / apr / bin :$MAVEN_HOME / bin :$PATH exportPATH = / usr / java / androidsdk / platform - tools: / usr / java / androidsdk / tools / bin :$ANDROID_HOME:$ANDROID_HOME / tools:$ANDROID_HOME / platform - tools:$ANDROID_SDK_HOME / tools:$ANDROID_SDK_HOME / platform - tools:$GRADLE_HOME / bin : / usr / local / apr / bin : / usr / java / apache - maven - 3.3 . 9 / bin : / root / shell: / usr / java / jdk / bin : / usr / lib64 / qt - 3.3 / bin : / usr / local / sbin: / usr / local / bin : / sbin: / bin : / usr / sbin: / usr / bin : / root / bin : / usr / local / git / bin exportMAVEN_OPTS = "-Xms1024m-Xmx1024m" 具体步骤 1.libc.so.6: version `GLIBC_2.14' not found 2.先安装androidsdk,生成证书文件夹 3.android list sdk -u 更新 ./android update sdk -u -t add-on,extra,platform,platform-tool,tool 包 http://services.gradle.org/distributions/ gradle安装包 注意 兼容性 yum whatprovides libstdc++.so.6 编译步骤 1.bulid.g 修改 2.linc 文件 3.命令 4.移动依赖的文件 5.壳 setting gradle clean build gradle assemble_devdebug 主工程 buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.1' } } 模块 PullToRefresh buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.0' } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 buildscript{ repositories{ jcenter() } dependencies{ classpath 'com.android.tools.build:gradle:2.3.1' } } def getCurrentTime(){ return newDate(). format ( "yyyyMMddHHmm" ,TimeZone.getTimeZone( "UTC" )) } apply plugin: 'com.android.application' android{ lintOptions{ abortOnErrorfalse } android.applicationVariants. all {variant - > variant.outputs.each{output - > def outputFile = output.outputFile if (outputFile! = null&&outputFile.name.endsWith( '.apk' )){ def buildType = variant.buildType.name def fileName = "andpl_V${defaultConfig.versionName}_${getCurrentTime()}${variant.productFlavors[0].name}.apk" output.outputFile = new File (outputFile.parent,fileName) } } } 3.jenkins配置 clean assemble${PRODUCT_FLAVOR}${BUILD_TYPE} --stacktrace --debug BUILD_TYPE Release PRODUCT_FLAVOR Beta CODE_BRANCH develop VERSION 1.0.0 编译指定productFlavor及buildType的apk $gradle assemble[productFlavor][buildType] 需要动态写入的参数有versionName、打包时间戳、是来自Jenkjins运行还是我们本地打包的标识符 把这三个参数与其在本地的默认值定义在gradle.properties中,然后在build.gradle变能引用。 本文转自 liqius 51CTO博客,原文链接:http://blog.51cto.com/szgb17/1965268,如需转载请自行联系原作者

优秀的个人博客,低调大师

,文件存储

文件存储 layout <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <EditText android:id="@+id/edit" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Type something here" /> </LinearLayout> main package demo.jq.com.filepersistencetest; import android.content.Context; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.TextUtils; import android.widget.EditText; import android.widget.Toast; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import static java.lang.System.out; /** * @author Jim */ public class MainActivity extends AppCompatActivity { private EditText edit; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); edit = (EditText) findViewById(R.id.edit); String inputText = load(); if (!TextUtils.isEmpty(inputText)) { edit.setText(inputText); edit.setSelection(inputText.length()); Toast.makeText(this,"Restoring succeeded",Toast.LENGTH_SHORT).show(); } } @Override protected void onDestroy() { super.onDestroy(); String inputText = edit.getText().toString(); save(inputText); } public void save(String inputText) { FileOutputStream out = null; BufferedWriter writer= null; try { out = openFileOutput("data", Context.MODE_PRIVATE); writer = new BufferedWriter(new OutputStreamWriter(out)); writer.write(inputText); } catch (IOException e) { e.printStackTrace(); } finally { try { if (writer != null) { writer.close(); } } catch (IOException e) { e.printStackTrace(); } } } public String load() { FileInputStream in = null; BufferedReader reader = null; StringBuilder content = new StringBuilder(); try { in = openFileInput("data"); reader = new BufferedReader(new InputStreamReader(in)); String line = ""; while ((line = reader.readLine()) != null) { content.append(line); } } catch (IOException e) { e.printStackTrace(); } finally { try { if (reader != null) { reader.close(); } } catch (IOException e) { e.printStackTrace(); } } return content.toString(); } } 本文转自TBHacker博客园博客,原文链接:http://www.cnblogs.com/jiqing9006/p/7693256.html如需转载请自行联系原作者

优秀的个人博客,低调大师

播放视频

播放视频 1.页面布局 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id="@+id/play" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Play" /> <Button android:id="@+id/pause" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Pause" /> <Button android:id="@+id/replay" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Replay" /> </LinearLayout> <VideoView android:id="@+id/video_view" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout> 2.配置权限 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 3.功能实现 package demo.jq.com.playvideotest; import android.content.pm.PackageManager; import android.net.Uri; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.Toast; import android.widget.VideoView; /** * @author jim */ public class MainActivity extends AppCompatActivity implements View.OnClickListener{ private VideoView videoView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); videoView = (VideoView) findViewById(R.id.video_view); Button play = (Button) findViewById(R.id.play); Button pause = (Button) findViewById(R.id.pause); Button replay = (Button) findViewById(R.id.replay); play.setOnClickListener(this); pause.setOnClickListener(this); replay.setOnClickListener(this); if (ContextCompat.checkSelfPermission(MainActivity.this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(MainActivity.this,new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE},1); } else { initVideoPath(); } } private void initVideoPath() { try { Uri uri = Uri.parse("android.resource://demo.jq.com.playvideotest/"+R.raw.video); videoView.setVideoURI(uri); } catch (Exception e) { e.printStackTrace(); } } @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { switch (requestCode) { case 1: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { initVideoPath(); } else { Toast.makeText(this,"拒绝权限将无法使用程序",Toast.LENGTH_SHORT).show(); finish(); } break; default: } } @Override public void onClick(View v) { switch (v.getId()) { case R.id.play: if (!videoView.isPlaying()) { videoView.start(); } break; case R.id.pause: if (videoView.isPlaying()) { videoView.pause(); } break; case R.id.replay: if (videoView.isPlaying()) { videoView.seekTo(0); videoView.resume(); } break; default: break; } } @Override public void onDestroy() { super.onDestroy(); if (videoView != null) { videoView.suspend(); } } } 真的可以播放哦,视频资源放在raw目录下了。 本文转自TBHacker博客园博客,原文链接:http://www.cnblogs.com/jiqing9006/p/7705051.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

重拾_01_开发环境搭建(eclipse)

一、下载安装Android SDK 1.下载地址 (1)官网(可FQ选择):http://developer.android.com/sdk/index.html (2)不可FQ选择:http://www.androiddevtools.cn/ 2.下载过程记录 这里选择第二种方式,进入http://www.androiddevtools.cn/,点击导航栏 Android SDK 工具 -> SDK Tools,选择一个版本进行安装,这里选择的是第二个版本(考虑可能最新版会不稳定)进行下载。 2.安装 二、参考资料 1.搭建Android开发环境——Eclipse

优秀的个人博客,低调大师

ChromeOS 逐渐“化”

谷歌在博客透露称,ChromeOS 底层将更广泛地与 Android 共用同样的技术栈。 一个相关的例子是,ChromeOS 之前一直使用自己的蓝牙协议栈,而现在已经转用 Android 的蓝牙协议栈。这种转换(从 Bluez 到 Fluoride)不仅提升了配对速度,还提高了蓝牙配对成功率和重连率。 谷歌认为这一变化有助于“手机和配件等不同设备更好地与 Chromebook 协同工作”。以蓝牙协议栈为例,大多数配件都是针对 Android 和移动设备而非 Chromebook 进行测试的。ChromeOS 的切换可以让笔记本电脑从现有的移动支持中受益。 谷歌还说道: 为了继续以更快、更大规模的方式向用户推出新的 Google AI 功能,我们将采用部分 Android 堆栈(例如 Android Linux 内核和 Android 框架)作为 ChromeOS 基础的一部分。 将基于 Android 的技术栈引入 ChromeOS 将使我们能够加快 ChromeOS 核心的 AI 创新步伐,简化工程工作,并帮助手机和配件等不同设备更好地与 Chromebook 配合使用。 由此可见,谷歌做出这一转变有几个原因,包括提高开发效率以及帮助手机和配件与 Chromebook 更好地兼容。但更重要的是,这能加速在 Chromebook 平台上启用更多的 AI 功能与工具。 考虑到除搜索、G Suite 和 Gmail 之外,对于大部份用户而言,Android 设备是他们与谷歌 AI 产品互动最频繁的设备。因此谷歌将 AI 开发的重心放在 Android 上也就不足为奇。如果 ChromeOS 也能转变为和 Android 共用同样的底层技术,那么将 AI 功能和工具移植到 ChromeOS 上的技术难度与开发成本将大幅下降。 但大家也不用期待很快就能在 Chromebook 上看到这项工作的成果。谷歌表示,虽然更换 ChromeOS 底层技术的相关开发工作已经开始,但更新「在相当长的时间内都还不会面向消费者推出」。一旦重大改动的 ChromeOS 准备就绪,谷歌承诺将带来「无缝」的过渡体验。 相关阅读:谷歌展示在 Android 虚拟机中运行 ChromeOS

优秀的个人博客,低调大师

项目回顾(二)

第二天: 任务一:给某个屏幕设置淡入淡出效果 //进行淡入淡出的效果 initAnimation(); private void initAnimation() { // TODO 自动生成的方法存根 AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);//透明度 alphaAnimation.setDuration(3000);//设置时长 rl_root.startAnimation(alphaAnimation); } private void initUI() { // TODO 自动生成的方法存根 tv_version_name = (TextView) findViewById(R.id.tv_version_name); rl_root = (RelativeLayout) findViewById(R.id.rl_root); } <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/launcher_bg" android:id="@+id/rl_root" tools:context=".SplashActivity" > ok,对项目的主题进行配置 <!-- Application theme. --> <style name="AppTheme" parent="AppBaseTheme"> <!-- All customizations that are NOT specific to a particular API-level can go here. --> </style> <!-- <TextView android:text="功能列表" android:gravity="center" android:textSize="20sp" android:textColor="#000" android:padding="10dp" android:background="#0f0" android:layout_width="match_parent" android:layout_height="wrap_content"/> --> <style name="TitleStyle"> <item name="android:gravity">center</item> <item name="android:textSize">20sp</item> <item name="android:textColor">#000</item> <item name="android:padding">10dp</item> <item name="android:background">#0f0</item> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">wrap_content</item> </style> <TextView style="@style/TitleStyle" android:text="功能列表" /> 自定义类进行内容的聚焦,用于滚动 import android.content.Context; import android.util.AttributeSet; import android.widget.TextView; public class FocusTextView extends TextView { //使用在通过java代码创建控件 public FocusTextView(Context context) { super(context); } //由系统调用(带属性+上下文环境构造方法xml to java对象) public FocusTextView(Context context, AttributeSet attrs) { super(context, attrs); } //由系统调用(带属性+上下文环境构造方法+布局文件中定义样式文件构造方法xml) public FocusTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } //这是第二种方法重写获取焦点的方法,由系统调用,调用的时候默认就能获取焦点,比textview好 @Override public boolean isFocused() { return true; } } <com.example.moblesafe73.view.FocusTextView android:layout_width="match_parent" android:layout_height="wrap_content" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:padding="5dp" android:singleLine="true" android:text="秋天秋天悄悄过去,留下小秘密,啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊" android:textColor="#000" > </com.example.moblesafe73.view.FocusTextView> 开始着手设置九宫格 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center" > <ImageView android:id="@+id/iv_icon" android:background="@drawable/ic_launcher" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <TextView android:id="@+id/tv_title" android:text="模块标题" android:textSize="18sp" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> <GridView android:id="@+id/gv_home" android:numColumns="3" android:verticalSpacing="10dp" android:layout_width="match_parent" android:layout_height="match_parent" > </GridView> import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.BaseAdapter; import android.widget.GridView; import android.widget.ImageView; import android.widget.TextView; public class HomeActivity extends Activity{ private String[] mTitleStrs; private int[] mDrawableIds; private GridView gv_home; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); initUI(); //初始化数据的方法 initData(); } private void initData() { //准备数据(文字(9组),图片(9张)) mTitleStrs = new String[]{ "手机防盗","通信卫士","软件管理","进程管理","流量统计","手机杀毒","缓存清理","高级工具","设置中心" }; mDrawableIds = new int[]{ R.drawable.home_safe,R.drawable.home_callmsgsafe, R.drawable.home_apps,R.drawable.home_taskmanager, R.drawable.home_netmanager,R.drawable.home_trojan, R.drawable.home_sysoptimize,R.drawable.home_tools,R.drawable.home_settings }; //九宫格控件设置数据适配器(等同ListView数据适配器) gv_home.setAdapter(new MyAdapter()); } class MyAdapter extends BaseAdapter{ @Override public int getCount() { //条目的总数 文字组数 == 图片张数 return mTitleStrs.length; } @Override public Object getItem(int position) { return mTitleStrs[position]; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { View view = View.inflate(getApplicationContext(), R.layout.gridview_item, null); TextView tv_title = (TextView) view.findViewById(R.id.tv_title); ImageView iv_icon = (ImageView) view.findViewById(R.id.iv_icon); tv_title.setText(mTitleStrs[position]); iv_icon.setBackgroundResource(mDrawableIds[position]); return view; } } private void initUI() { gv_home = (GridView) findViewById(R.id.gv_home); } } 本文转自眉间雪 51CTO博客,原文链接:http://blog.51cto.com/13348847/2047665,如需转载请自行联系原作者

优秀的个人博客,低调大师

常用代码片段

常用代码片段 //1.拨打电话 // 给移动客服10086拨打电话 Uri uri = Uri.parse("tel:10086"); Intent intent = new Intent(Intent.ACTION_DIAL, uri); startActivity(intent); //2.发送短信 // 给10086发送内容为“Hello”的短信 Uri uri = Uri.parse("smsto:10086"); Intent intent = new Intent(Intent.ACTION_SENDTO, uri); intent.putExtra("sms_body", "Hello"); startActivity(intent); //3.发送彩信(相当于发送带附件的短信) Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra("sms_body", "Hello"); Uri uri = Uri.parse("content://media/external/images/media/23"); intent.putExtra(Intent.EXTRA_STREAM, uri); intent.setType("image/png"); startActivity(intent); //4.打开浏览器: // 打开Google主页 Uri uri = Uri.parse("http://www.baidu.com"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); //5.发送电子邮件:(阉割了Google服务的没戏!!!!) // 给someone@domain.com发邮件 Uri uri = Uri.parse("mailto:someone@domain.com"); Intent intent = new Intent(Intent.ACTION_SENDTO, uri); startActivity(intent); // 给someone@domain.com发邮件发送内容为“Hello”的邮件 Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_EMAIL, "someone@domain.com"); intent.putExtra(Intent.EXTRA_SUBJECT, "Subject"); intent.putExtra(Intent.EXTRA_TEXT, "Hello"); intent.setType("text/plain"); startActivity(intent); // 给多人发邮件 Intent intent=new Intent(Intent.ACTION_SEND); String[] tos = {"1@abc.com", "2@abc.com"}; // 收件人 String[] ccs = {"3@abc.com", "4@abc.com"}; // 抄送 String[] bccs = {"5@abc.com", "6@abc.com"}; // 密送 intent.putExtra(Intent.EXTRA_EMAIL, tos); intent.putExtra(Intent.EXTRA_CC, ccs); intent.putExtra(Intent.EXTRA_BCC, bccs); intent.putExtra(Intent.EXTRA_SUBJECT, "Subject"); intent.putExtra(Intent.EXTRA_TEXT, "Hello"); intent.setType("message/rfc822"); startActivity(intent); //6.显示地图: // 打开Google地图中国北京位置(北纬39.9,东经116.3) Uri uri = Uri.parse("geo:39.9,116.3"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); //7.路径规划 // 路径规划:从北京某地(北纬39.9,东经116.3)到上海某地(北纬31.2,东经121.4) Uri uri = Uri.parse("http://maps.google.com/maps?f=d&saddr=39.9 116.3&daddr=31.2 121.4"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); //8.多媒体播放: Intent intent = new Intent(Intent.ACTION_VIEW); Uri uri = Uri.parse("file:///sdcard/foo.mp3"); intent.setDataAndType(uri, "audio/mp3"); startActivity(intent); //获取SD卡下所有音频文件,然后播放第一首=-= Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); //9.打开摄像头拍照: // 打开拍照程序 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, 0); // 取出照片数据 Bundle extras = intent.getExtras(); Bitmap bitmap = (Bitmap) extras.get("data"); //另一种: //调用系统相机应用程序,并存储拍下来的照片 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); time = Calendar.getInstance().getTimeInMillis(); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(Environment .getExternalStorageDirectory().getAbsolutePath()+"/tucue", time + ".jpg"))); startActivityForResult(intent, ACTIVITY_GET_CAMERA_IMAGE); //10.获取并剪切图片 // 获取并剪切图片 Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); intent.putExtra("crop", "true"); // 开启剪切 intent.putExtra("aspectX", 1); // 剪切的宽高比为1:2 intent.putExtra("aspectY", 2); intent.putExtra("outputX", 20); // 保存图片的宽和高 intent.putExtra("outputY", 40); intent.putExtra("output", Uri.fromFile(new File("/mnt/sdcard/temp"))); // 保存路径 intent.putExtra("outputFormat", "JPEG");// 返回格式 startActivityForResult(intent, 0); // 剪切特定图片 Intent intent = new Intent("com.android.camera.action.CROP"); intent.setClassName("com.android.camera", "com.android.camera.CropImage"); intent.setData(Uri.fromFile(new File("/mnt/sdcard/temp"))); intent.putExtra("outputX", 1); // 剪切的宽高比为1:2 intent.putExtra("outputY", 2); intent.putExtra("aspectX", 20); // 保存图片的宽和高 intent.putExtra("aspectY", 40); intent.putExtra("scale", true); intent.putExtra("noFaceDetection", true); intent.putExtra("output", Uri.parse("file:///mnt/sdcard/temp")); startActivityForResult(intent, 0); //11.打开Google Market // 打开Google Market直接进入该程序的详细页面 Uri uri = Uri.parse("market://details?id=" + "com.demo.app"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); //12.进入手机设置界面: // 进入无线网络设置界面(其它可以举一反三) Intent intent = new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS); startActivityForResult(intent, 0); //13.安装apk: Uri installUri = Uri.fromParts("package", "xxx", null); returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri); //14.卸载apk: Uri uri = Uri.fromParts("package", strPackageName, null); Intent it = new Intent(Intent.ACTION_DELETE, uri); startActivity(it); //15.发送附件: Intent it = new Intent(Intent.ACTION_SEND); it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text"); it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/eoe.mp3"); sendIntent.setType("audio/mp3"); startActivity(Intent.createChooser(it, "Choose Email Client")); //16.进入联系人页面: Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(People.CONTENT_URI); startActivity(intent); //17.查看指定联系人: Uri personUri = ContentUris.withAppendedId(People.CONTENT_URI, info.id);//info.id联系人ID Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(personUri); startActivity(intent);

优秀的个人博客,低调大师

使用LocationManager定位

版权声明:本文可能为博主原创文章,若标明出处可随便转载。 https://blog.csdn.net/Jailman/article/details/78030105 git地址 https://github.com/yayaa/LocationManager 安装 在gradle里边添加 compile 'com.yayandroid:LocationManager:2.0.4' AndroidManifest.xml权限添加 <!-- Required to check whether user has network connection or not --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> <!-- Dangerous Permissions --> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 添加presenterX类 package online.geekgalaxy.layoutlearn; /** * Created by jailman on 2017/9/19. */ import android.location.Location; import android.text.TextUtils; import com.yayandroid.locationmanager.constants.FailType; import com.yayandroid.locationmanager.constants.ProcessType; public class presenter { private SampleView sampleView; public presenter(SampleView view) { this.sampleView = view; } public void destroy() { sampleView = null; } public void onLocationChanged(Location location) { sampleView.dismissProgress(); setText(location); } public void onLocationFailed(@FailType int failType) { sampleView.dismissProgress(); switch (failType) { case FailType.TIMEOUT: { sampleView.setText("Couldn't get location, and timeout!"); break; } case FailType.PERMISSION_DENIED: { sampleView.setText("Couldn't get location, because user didn't give permission!"); break; } case FailType.NETWORK_NOT_AVAILABLE: { sampleView.setText("Couldn't get location, because network is not accessible!"); break; } case FailType.GOOGLE_PLAY_SERVICES_NOT_AVAILABLE: { sampleView.setText("Couldn't get location, because Google Play Services not available!"); break; } case FailType.GOOGLE_PLAY_SERVICES_CONNECTION_FAIL: { sampleView.setText("Couldn't get location, because Google Play Services connection failed!"); break; } case FailType.GOOGLE_PLAY_SERVICES_SETTINGS_DIALOG: { sampleView.setText("Couldn't display settingsApi dialog!"); break; } case FailType.GOOGLE_PLAY_SERVICES_SETTINGS_DENIED: { sampleView.setText("Couldn't get location, because user didn't activate providers via settingsApi!"); break; } case FailType.VIEW_DETACHED: { sampleView.setText("Couldn't get location, because in the process view was detached!"); break; } case FailType.VIEW_NOT_REQUIRED_TYPE: { sampleView.setText("Couldn't get location, " + "because view wasn't sufficient enough to fulfill given configuration!"); break; } case FailType.UNKNOWN: { sampleView.setText("Ops! Something went wrong!"); break; } } } public void onProcessTypeChanged(@ProcessType int newProcess) { switch (newProcess) { case ProcessType.GETTING_LOCATION_FROM_GOOGLE_PLAY_SERVICES: { sampleView.updateProgress("Getting Location from Google Play Services..."); break; } case ProcessType.GETTING_LOCATION_FROM_GPS_PROVIDER: { sampleView.updateProgress("Getting Location from GPS..."); break; } case ProcessType.GETTING_LOCATION_FROM_NETWORK_PROVIDER: { sampleView.updateProgress("Getting Location from Network..."); break; } case ProcessType.ASKING_PERMISSIONS: case ProcessType.GETTING_LOCATION_FROM_CUSTOM_PROVIDER: // Ignored break; } } private void setText(Location location) { String appendValue = location.getLatitude() + ", " + location.getLongitude() + "\n"; String newValue; CharSequence current = sampleView.getText(); if (!TextUtils.isEmpty(current)) { newValue = current + appendValue; } else { newValue = appendValue; } sampleView.setText(newValue); } public interface SampleView { String getText(); void setText(String text); void updateProgress(String text); void dismissProgress(); } } 操作view显示坐标的类 package online.geekgalaxy.layoutlearn; import android.app.ProgressDialog; import android.location.Location; import android.os.Bundle; import android.view.View; import android.view.Window; import android.widget.Button; import android.widget.TextView; import com.yayandroid.locationmanager.base.LocationBaseActivity; import com.yayandroid.locationmanager.configuration.Configurations; import com.yayandroid.locationmanager.configuration.LocationConfiguration; import com.yayandroid.locationmanager.constants.FailType; import com.yayandroid.locationmanager.constants.ProcessType; /** * Created by jailman on 2017/9/19. */ public class location extends LocationBaseActivity implements presenter.SampleView { private ProgressDialog progressDialog; private TextView locationText; private presenter Presenter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.location); final Button locate = (Button) findViewById(R.id.button6); locate.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { locationText = (TextView) findViewById(R.id.textView); Presenter = new presenter(location.this); getLocation(); } }); } @Override protected void onDestroy() { super.onDestroy(); Presenter.destroy(); } @Override public LocationConfiguration getLocationConfiguration() { return Configurations.defaultConfiguration("Gimme the permission!", "Would you mind to turn GPS on?"); } @Override public void onLocationChanged(Location location) { Presenter.onLocationChanged(location); } @Override public void onLocationFailed(@FailType int failType) { Presenter.onLocationFailed(failType); } @Override public void onProcessTypeChanged(@ProcessType int processType) { Presenter.onProcessTypeChanged(processType); } @Override protected void onResume() { super.onResume(); if (getLocationManager().isWaitingForLocation() && !getLocationManager().isAnyDialogShowing()) { displayProgress(); } } @Override protected void onPause() { super.onPause(); dismissProgress(); } private void displayProgress() { if (progressDialog == null) { progressDialog = new ProgressDialog(this); progressDialog.getWindow().addFlags(Window.FEATURE_NO_TITLE); progressDialog.setMessage("Getting location..."); } if (!progressDialog.isShowing()) { progressDialog.show(); } } @Override public String getText() { return locationText.getText().toString(); } @Override public void setText(String text) { locationText.setText(text); } @Override public void updateProgress(String text) { if (progressDialog != null && progressDialog.isShowing()) { progressDialog.setMessage(text); } } @Override public void dismissProgress() { if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } } } view <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bg3"> <TextView android:id="@+id/textView" android:layout_width="261dp" android:layout_height="137dp" android:layout_marginBottom="8dp" android:layout_marginLeft="8dp" android:layout_marginRight="8dp" android:layout_marginTop="8dp" android:text="位置信息" android:textAlignment="center" android:textColor="@android:color/holo_red_dark" android:textSize="18sp" android:textStyle="bold" app:layout_constraintBottom_toTopOf="@+id/button6" app:layout_constraintHorizontal_bias="0.504" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.637" /> <Button android:id="@+id/button6" android:layout_width="138dp" android:layout_height="75dp" android:layout_marginBottom="156dp" android:layout_marginLeft="16dp" android:layout_marginRight="8dp" android:background="@android:drawable/btn_default" android:backgroundTint="@android:color/holo_orange_dark" android:text="locate" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintHorizontal_bias="0.481" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" /> </android.support.constraint.ConstraintLayout>

优秀的个人博客,低调大师

开发环境搭建

下面的可以当作一个引路人,但是搭建还得自己是试试。 这里面把文章中没有的地址写上。 sdk下载地址http://developer.android.com/sdk/installing/index.html 里面有各种版本的,我下载的压缩版的。 引言 本系列适合0基础的人员,因为我就是从0开始的,此系列记录我步入Android开发的一些经验分享,望与君共勉!作为Android队伍中的一个新人的我,如果有什么不对的地方,还望不吝赐教。 在开始Android开发之旅启动之前,首先要搭建环境,然后创建一个简单的HelloWorld。本文的主题如下: 1、环境搭建 1.1、JDK安装 1.2、Eclipse安装 1.3、Android SDK安装 1.4、ADT安装 1.5、创建AVD 2、HelloWorld 1、环境搭建 1.1、JDK安装 如果你还没有JDK的话,可以去这里下载,接下来的工作就是安装提示一步一步走。设置环境变量步骤如下: 我的电脑->属性->高级->环境变量->系统变量中添加以下环境变量: JAVA_HOME值为: D:\Program Files\Java\jdk1.6.0_18(你安装JDK的目录) CLASSPATH值为:.;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\bin; Path: 在开始追加 %JAVA_HOME%\bin; NOTE:前面四步设置环境变量对搭建Android开发环境不是必须的,可以跳过。 安装完成之后,可以在检查JDK是否安装成功。打开cmd窗口,输入java –version 查看JDK的版本信息。出现类似下面的画面表示安装成功了: 图1、验证JDK安装是否成功 1.2、Eclipse安装 如果你还么有Eclipse的话,可以去这里下载,下载如下图所示的Eclipse IDE for Java Developers(92M)的win 32bit版: 图2、Eclipse下载 解压之后即可使用。 1.3、Android SDK安装 在Android Developers下载android-sdk_r05-windows.zip,下载完成后解压到任意路径。 运行SDK Setup.exe,点击Available Packages。如果没有出现可安装的包,请点击Settings,选中Misc中的"Force https://..."这项,再点击Available Packages 。 选择希望安装的SDK及其文档或者其它包,点击Installation Selected、Accept All、Install Accepted,开始下载安装所选包 在用户变量中新建PATH值为:Android SDK中的tools绝对路径(本机为D:\AndroidDevelop\android-sdk-windows\tools)。 图2、设置Android SDK的环境变量 “确定”后,重新启动计算机。重启计算机以后,进入cmd命令窗口,检查SDK是不是安装成功。 运行 android –h 如果有类似以下的输出,表明安装成功: 图3、验证Android SDK是否安装成功 1.4、ADT安装 打开 Eclipse IDE,进入菜单中的 "Help" -> "Install New Software" 点击Add...按钮,弹出对话框要求输入Name和Location:Name自己随便取,Location输入http://dl-ssl.google.com/android/eclipse。如下图所示: 确定返回后,在work with后的下拉列表中选择我们刚才添加的ADT,我们会看到下面出有Developer Tools,展开它会有Android DDMS和Android Development Tool,勾选他们。 如下图所示: 然后就是按提示一步一步next。 完成之后: 选择Window > Preferences... 在左边的面板选择Android,然后在右侧点击Browse...并选中SDK路径,本机为: D:\AndroidDevelop\android-sdk-windows 点击Apply、OK。配置完成。 1.5、创建AVD 为使Android应用程序可以在模拟器上运行,必须创建AVD。 1、在Eclipse中。选择Windows > Android SDK and AVD Manager 2、点击左侧面板的Virtual Devices,再右侧点击New 3、填入Name,选择Target的API,SD Card大小任意,Skin随便选,Hardware目前保持默认值 4、点击Create AVD即可完成创建AVD 注意:如果你点击左侧面板的Virtual Devices,再右侧点击New ,而target下拉列表没有可选项时,这时候你: 点击左侧面板的Available Packages,在右侧勾选https://dl-ssl.google.com/android/repository/repository.xml,如下图所示: 然后点击Install Selected按钮,接下来就是按提示做就行了 要做这两步,原因是在1.3、Android SDK安装中没有安装一些必要的可用包(Available Packages)。 2、HelloWorld 通过File -> New -> Project 菜单,建立新项目"Android Project" 然后填写必要的参数,如下图所示:(注意这里我勾选的是Google APIs,你可以选你喜欢的,但你要创建相应的AVD) 相关参数的说明: Project Name: 包含这个项目的文件夹的名称。 Package Name: 包名,遵循JAVA规范,用包名来区分不同的类是很重要的,我用的是helloworld.test。 Activity Name: 这是项目的主类名,这个类将会是Android的Activity类的子类。一个Activity类是一个简单的启动程序和控制程序的类。它可以根据需要创建界面,但不是必须的。 Application Name: 一个易读的标题在你的应用程序上。 在"选择栏"的 "Use default location" 选项,允许你选择一个已存在的项目。 点击Finish后,点击Eclipse的Run菜单选择Run Configurations… 选择“Android Application”,点击在左上角(按钮像一张纸上有个“+”号)或者双击“Android Application”, 有个新的选项“New_configuration”(可以改为我们喜欢的名字)。 在右侧Android面板中点击Browse…,选择HelloWorld 在Target面板的Automatic中勾选相应的AVD,如果没有可用的AVD的话,你需要点击右下角的Manager…,然后新建相应的AVD。如下图所示: 然后点Run按钮即可,运行成功的话会有Android的模拟器界面,如下图所示: 本文转自茄子_2008博客园博客,原文链接:http://www.cnblogs.com/xd502djj/p/4161914.html,如需转载请自行联系原作者。

优秀的个人博客,低调大师

播放音频

播放音频 1.设置界面 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:id="@+id/play" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Play" /> <Button android:id="@+id/pause" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Pause" /> <Button android:id="@+id/stop" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Stop" /> </LinearLayout> 2.配置权限 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="demo.jq.com.playaudiotest"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> </manifest> 3.实现功能 package demo.jq.com.playaudiotest; import android.content.pm.PackageManager; import android.media.MediaPlayer; import android.net.Uri; import android.os.Environment; import android.support.annotation.NonNull; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.support.v4.os.EnvironmentCompat; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.Toast; import java.io.File; import java.util.jar.Manifest; /** * @author jim * implements View.OnClickListener 继承接口 */ public class MainActivity extends AppCompatActivity implements View.OnClickListener{ private MediaPlayer mediaPlayer = new MediaPlayer(); private static final String TAG = "MainActivity"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button play = (Button) findViewById(R.id.play); Button pause = (Button) findViewById(R.id.pause); Button stop = (Button) findViewById(R.id.stop); play.setOnClickListener(this); pause.setOnClickListener(this); stop.setOnClickListener(this); if (ContextCompat.checkSelfPermission(MainActivity.this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(MainActivity.this,new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE},1); } else { initMediaPlayer(); } } private void initMediaPlayer() { try { Uri setDataSourceuri = Uri.parse("android.resource://demo.jq.com.playaudiotest/"+R.raw.music); mediaPlayer.setDataSource(this,setDataSourceuri); mediaPlayer.prepare(); } catch (Exception e) { e.printStackTrace(); } } @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { switch (requestCode) { case 1: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { initMediaPlayer(); } else { Toast.makeText(this,"拒绝权限将无法使用程序",Toast.LENGTH_SHORT).show(); finish(); } break; default: } } @Override public void onClick(View v) { switch (v.getId()) { case R.id.play: if (!mediaPlayer.isPlaying()) { mediaPlayer.start(); } break; case R.id.pause: if (mediaPlayer.isPlaying()) { mediaPlayer.pause(); } break; case R.id.stop: if (mediaPlayer.isPlaying()) { mediaPlayer.reset(); initMediaPlayer(); } break; default: break; } } @Override public void onDestroy() { super.onDestroy(); if (mediaPlayer != null) { mediaPlayer.stop(); mediaPlayer.release(); } } } 这里有个关键就是获取音频文件的地址。 有几种情况,一种是播放sd卡,一种是播放应用中的音频,一种是播放在线的。 上面的案例是播放应用中的。 本文转自TBHacker博客园博客,原文链接:http://www.cnblogs.com/jiqing9006/p/7704772.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

Sqlbean 版 1.1.0 发布

Sqlbean是一款使用Java面向对象思想来编写并生成Sql语句的工具,在此基础上对Android SQLite实现轻量级插件支持。其中内置大量常用SQL执行的方法,可以非常方便的达到你想要的目的,相对复杂的SQL语句也得以支持,在常规的项目开发几乎做到不写SQL,可以有效的提高项目开发的效率,让开发者更专注于业务代码的编写。 🚀特点: 零入侵, 自动建表, 连表查询, 乐观锁,分页 💻环境: Android 4.0+ Sqlbean-Core与Java-Spring版请移步这里👉gitee,github 本次更新 1:优化生成的id以及自动生成的插入时间和更新时间注入到bean实体中; 2:重构简单条件,旧的where条件相关方法标识为过期,未来版本将会删除; 3:修改常量类生成由命名开头改为以命名开头改为以结尾(因为$开头开发工具无法提示); 4:更新pom依赖; 5:修复一些问题;

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册