android Home键监听

监听工具类 import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.util.Log; public class HomeWatcher { static final String TAG = “HomeWatcher”; private Context mContext; private IntentFilter mFilter; private OnHomePressedListener mListener; private InnerRecevier mRecevier; // 回调接口 public interface OnHomePressedListener { public void onHomePressed(); public void onHomeLongPressed(); } public HomeWatcher(Context context) { mContext = context; mRecevier = new InnerRecevier(); mFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); } /** 设置监听 @param listener */ public void setOnHomePressedListener(OnHomePressedListener listener) { mListener = listener; } /** ...

2017年2月26日 · 2 分钟 · 天边的星星

Android 蓝牙4.0 BLE 理解

转载自:http://blog.csdn.net/chaoyue0071/article/details/43450183/ 本文简单结合两篇文章 http://blog.csdn.net/hellogv/article/details/24267685 http://blog.csdn.net/jimoduwu/article/details/21604215 在BLE协议中,有两个角色,周边(Periphery)和中央(Central),一个中央可以同时连接多个周边,但是一个周边某一时刻只能连接一个中央。但是不管是Periphery还是Central都是可以实现 GATT server 和 GATT client去传输数据,但是无法同时都是。 大概了解了概念后,看看Android BLE SDK的四个关键类(class): a) BluetoothGattServer作为周边来提供数据; BluetoothGattServerCallback返回周边的状态。 b) BluetoothGatt作为中央来使用和处理数据;BluetoothGattCallback返回中央的状态和周边提供的数据。 因为我们讨论的是Android的BLE SDK,下面所有的BluetoothGattServer代表周边,BluetoothGatt代表中央。 一.创建一个周边(虽然目前周边API在Android手机上不工作,但还是看看) a)先看看周边用到的class,蓝色椭圆 b)说明: 每一个周边BluetoothGattServer,包含多个服务Service,每一个Service包含多个特征Characteristic。 1.new一个特征:character = new BluetoothGattCharacteristic( UUID.fromString(characteristicUUID), BluetoothGattCharacteristic.PROPERTY_NOTIFY, BluetoothGattCharacteristic.PERMISSION_READ); 2.new一个服务:service = new BluetoothGattService(UUID.fromString(serviceUUID), BluetoothGattService.SERVICE_TYPE_PRIMARY); 3.把特征添加到服务:service.addCharacteristic(character); 4.获取BluetoothManager:manager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); 5.获取/打开周边:BluetoothGattServer server = manager.openGattServer(this, new BluetoothGattServerCallback(){…}); 6.把service添加到周边:server.addService(service); 7.开始广播service:Google还没有广播Service的API,等吧!!!!!所以目前我们还不能让一个Android手机作为周边来提供数据。 二.创建一个中央(这次不会让你失望,可以成功创建并且连接到周边的) a)先看看中央用到的class,蓝色椭圆 b)说明: 为了拿到中央BluetoothGatt,可要爬山涉水十八弯: 1.先拿到BluetoothManager:bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); 2.再拿到BluetoothAdapt:btAdapter = bluetoothManager.getAdapter(); 3.开始扫描:btAdapter.startLeScan( BluetoothAdapter.LeScanCallback); 4.从LeScanCallback中得到BluetoothDevice:public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) {…..} 5.用BluetoothDevice得到BluetoothGatt:gatt = device.connectGatt(this, true, gattCallback); 终于拿到中央BluetoothGatt了,它有一堆方法(查API吧),调用这些方法,你就可以通过BluetoothGattCallback和周边BluetoothGattServer交互了。 官方有给出BLE 通信的sample ,下面是牛人简化了代码,简化得简单明了 本文来自http://blog.csdn.net/hellogv/ ,引用必须注明出处! 最近穿戴设备发展得很火,把相关技术也带旺了,其中一项是BLE(Bluetooth Low Energy)。BLE是蓝牙4.0的核心Profile,主打功能是快速搜索,快速连接,超低功耗保持连接和传输数据,弱点是数据传输速率低,由于BLE的低功耗特点,因此普遍用于穿戴设备。Android 4.3才开始支持BLE API,所以请各位客官把本文代码运行在蓝牙4.0和Android 4.3及其以上的系统,另外本文所用的BLE终端是一个蓝牙4.0的串口蓝牙模块。 PS:我的i9100刷了4.4系统后,竟然也能跟BLE蓝牙模块通信。 ...

2017年2月25日 · 6 分钟 · 天边的星星

Android 6.0 – 动态权限管理的解决方案

这里以单个存储权限为例: · 在 Manifest 中添加访问权限:(只需设置可写,因为可写必定可读) 动态申请权限的过程: = Build.VERSION_CODES.M) { // 检查该权限是否已经获取 int i = ContextCompat.checkSelfPermission(this, permissions[0]); // 权限是否已经 授权 GRANTED—授权 DINIED—拒绝 if (i != PackageManager.PERMISSION_GRANTED) { // 如果没有授予该权限,就去提示用户请求 showDialogTipUserRequestPermission(); } } } // 提示用户该请求权限的弹出框 private void showDialogTipUserRequestPermission() { new AlertDialog.Builder(this) .setTitle(“存储权限不可用”) .setMessage(“由于支付宝需要获取存储空间,为你存储个人信息;\n否则,您将无法正常使用支付宝”) .setPositiveButton(“立即开启”, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { startRequestPermission(); } }) .setNegativeButton(“取消”, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }).setCancelable(false).show(); } ...

2017年2月25日 · 3 分钟 · 天边的星星

Android 中gitWindow可以做的事情

View view = getWindow().getDecorView().findViewById(R.id.activity_main); if (view == null) return; ViewParent viewParent = view.getParent(); if (viewParent instanceof FrameLayout) { final FrameLayout frameParent = (FrameLayout) viewParent;//整个父布局 final LinearLayout linearLayout = new LinearLayout(this);//新建一个LinearLayout linearLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setBackgroundResource(#88000000);//背景设置灰色透明 linearLayout.setGravity(Gravity.CENTER_HORIZONTAL); linearLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { frameParent.removeView(linearLayout); } }); Rect rect = new Rect(); Point point = new Point(); nearby.getGlobalVisibleRect(rect, point);//获得nearby这个控件的宽高以及XY坐标 nearby这个控件对应就是需要高亮显示的地方 ImageView topGuideview = new ImageView(this); topGuideview.setLayoutParams(new ViewGroup.LayoutParams(rect.width(), rect.height())); topGuideview.setBackgroundResource(R.drawable.iv_topguide); ...

2017年2月20日 · 1 分钟 · 天边的星星

Socket请求网页

Java Socket现实简单的HTTP服务 http://jiangzhengjun.iteye.com/blog/512380 Java socket 访问网页 http://blog.csdn.net/yilip/article/details/45195713 import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.Socket; public class WebpageSocket { private static int port = 80; private static String hostname = “www.iteye.com”; public static void main(String[] args) throws Exception{ Socket socket = new Socket(hostname, port); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), “utf-8”)); writer.write(“GET ” + “/ask” + ” HTTP/1.0\r\n”); writer.write(“HOST:” + hostname + “\r\n”); writer.write(“Accept:*/*\r\n”); writer.write(“\r\n”); writer.flush(); BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), “utf-8”)); String line = null; while ((line = reader.readLine()) != null) { System.out.println(line); } reader.close(); writer.close(); socket.close(); } } ...

2017年1月4日 · 3 分钟 · 天边的星星

高德地图知识汇总

//设置缩放级别 aMap.moveCamera(CameraUpdateFactory.zoomTo(17)); //将地图移动到定位点 aMap.moveCamera(CameraUpdateFactory.changeLatLng(new LatLng(amapLocation.getLatitude(), amapLocation.getLongitude()))); //点击定位按钮 能够将地图的中心移动到定位点 mListener.onLocationChanged(amapLocation); //添加图钉 aMap.addMarker(getMarkerOptions(amapLocation)); //获取定位信息 StringBuffer buffer = new StringBuffer(); buffer.append(amapLocation.getCountry() + “” + amapLocation.getProvince() + “” + amapLocation.getCity() + “” + amapLocation.getProvince() + “” + amapLocation.getDistrict() + “” + amapLocation.getStreet() + “” + amapLocation.getStreetNum()); Toast.makeText(getApplicationContext(), buffer.toString(), Toast.LENGTH_LONG).show(); isFirstLoc = false; //定位的小图标 默认是蓝点 这里自定义一团火,其实就是一张图片 MyLocationStyle myLocationStyle = new MyLocationStyle(); myLocationStyle.myLocationIcon(BitmapDescriptorFactory.fromResource(R.mipmap.firetwo)); myLocationStyle.radiusFillColor(android.R.color.transparent); myLocationStyle.strokeColor(android.R.color.transparent); aMap.setMyLocationStyle(myLocationStyle); //定位 private void initLoc() { //初始化定位 mLocationClient = new AMapLocationClient(getApplicationContext()); //设置定位回调监听 mLocationClient.setLocationListener(this); //初始化定位参数 mLocationOption = new AMapLocationClientOption(); //设置定位模式为高精度模式,Battery_Saving为低功耗模式,Device_Sensors是仅设备模式 mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy); //设置是否返回地址信息(默认返回地址信息) mLocationOption.setNeedAddress(true); //设置是否只定位一次,默认为false mLocationOption.setOnceLocation(false); //设置是否强制刷新WIFI,默认为强制刷新 mLocationOption.setWifiActiveScan(true); //设置是否允许模拟位置,默认为false,不允许模拟位置 mLocationOption.setMockEnable(false); //设置定位间隔,单位毫秒,默认为2000ms mLocationOption.setInterval(2000); //给定位客户端对象设置定位参数 mLocationClient.setLocationOption(mLocationOption); //启动定位 mLocationClient.startLocation(); } ...

2016年12月18日 · 4 分钟 · 天边的星星

高德地图,定位 ,中间固定点拖动获取位置

import android.graphics.Color; import android.os.Bundle; import android.text.TextUtils; import android.util.Log; import android.view.View; import android.view.ViewTreeObserver; import android.view.animation.LinearInterpolator; import android.widget.TextView; import android.widget.Toast; import com.amap.api.location.AMapLocation; import com.amap.api.location.AMapLocationClient; import com.amap.api.location.AMapLocationClientOption; import com.amap.api.location.AMapLocationListener; import com.amap.api.maps.AMap; import com.amap.api.maps.CameraUpdateFactory; import com.amap.api.maps.LocationSource; import com.amap.api.maps.MapView; import com.amap.api.maps.UiSettings; import com.amap.api.maps.model.CameraPosition; import com.amap.api.maps.model.LatLng; import com.amap.api.maps.model.Marker; import com.amap.api.maps.model.MarkerOptions; import com.amap.api.maps.model.animation.Animation; import com.amap.api.maps.model.animation.RotateAnimation; import com.amap.api.services.core.LatLonPoint; import com.amap.api.services.geocoder.GeocodeResult; import com.amap.api.services.geocoder.GeocodeSearch; import com.amap.api.services.geocoder.RegeocodeQuery; import com.amap.api.services.geocoder.RegeocodeResult; import com.tlh.gczp.R; import com.tlh.gczp.mvp.view.BaseUIActivity; import butterknife.BindView; import butterknife.ButterKnife; /** * 地图选点 */ public class AMapSelectPointActivity extends BaseUIActivity implements LocationSource { public static String TITLE_TAG = "title_str";//标题key public static String RESULT_TAG = "result_str";//返回数据key String titleStr = "地图";//标题 @BindView(R.id.activity_amapselectpoint_map) MapView mMapView; @BindView(R.id.activity_amapselectpoint_text) TextView addressTxtView;//位置 AMap aMap;//地图 private UiSettings mUiSettings;//定义一个UiSettings对象 //声明AMapLocationClient类对象 public AMapLocationClient mLocationClient = null; //声明定位回调监听器 public AMapLocationListener mLocationListener; //声明AMapLocationClientOption对象 public AMapLocationClientOption mLocationOption = null; OnLocationChangedListener listener; MarkerOptions markerCenter = new MarkerOptions();//中心点 Marker marker;//中间 GeocodeSearch geocodeSearch;//地理位置查询 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentViewItem(R.layout.activity_amapselectpont); ButterKnife.bind(this); //在activity执行onCreate时执行mMapView.onCreate(savedInstanceState),实现地图生命周期管理 mMapView.onCreate(savedInstanceState); rightBtn.setTextColor(Color.parseColor("#fcc900")); initData(); showPage(); } /** * 实例化数据 */ private void initData() { initMap(); titleStr = getIntent().getStringExtra(TITLE_TAG); if (TextUtils.isEmpty(titleStr)){ titleStr = "地图"; } setPageName(titleStr); currentPageName = titleStr; setRightTxt(getString(R.string.str_common_finish), new View.OnClickListener() { @Override public void onClick(View view) { searchAddressByLat(marker.getPosition()); } }); } private void initMap() {//实例化Map geocodeSearch = new GeocodeSearch(this); //初始化地图变量 if (aMap == null) { aMap = mMapView.getMap(); } aMap.setMapType(AMap.MAP_TYPE_NORMAL); mUiSettings = aMap.getUiSettings();//实例化UiSettings类 mUiSettings.setZoomControlsEnabled(true); //定位按钮 aMap.setLocationSource(this);// 设置定位监听 mUiSettings.setMyLocationButtonEnabled(true); // 显示默认的定位按钮 aMap.setMyLocationEnabled(true);// 可触发定位并显示定位层 mUiSettings.setScaleControlsEnabled(true);//显示比例尺控件 mUiSettings.setAllGesturesEnabled(true); mUiSettings.setCompassEnabled(true);//指南针 // LatLng latLng = new LatLng(39.906901, 116.397972); // final Marker marker = aMap.addMarker(new MarkerOptions(). // position(latLng). // title("北京"). // snippet("DefaultMarker")); // final Marker marker = aMap.addMarker(new MarkerOptions()); // MarkerOptions markeroptions = new MarkerOptions(); // markeroptions.position(latLng); // markeroptions.title("当前位置"); // markeroptions.visible(true); // BitmapDescriptor bitmapDescriptor= BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(getResources(),R.mipmap.positioning_normal)); // markeroptions.icon(bitmapDescriptor); // aMap.addMarker(markeroptions); mMapView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { Log.e("mMapView","onGlobalLayout===---123"); marker = aMap.addMarker(new MarkerOptions()); Animation animation = new RotateAnimation(marker.getRotateAngle(), marker.getRotateAngle() + 720, 0, 0, 0); long duration = 1000L; animation.setDuration(duration); animation.setInterpolator(new LinearInterpolator()); marker.setAnimation(animation); marker.startAnimation(); marker.setPositionByPixels(mMapView.getWidth()/2, mMapView.getHeight()/2); } }); LatLng ll = new LatLng(34.6006623972045,108.97923588752748); markerCenter.position(ll); markerCenter.visible(true); markerCenter.title("中心点"); // BitmapDescriptor bitmapDescriptor= BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(getResources(),R.mipmap.icon_nearby)); // markerCenter.icon(bitmapDescriptor); aMap.addMarker(markerCenter); //初始化AMapLocationClientOption对象 mLocationOption = new AMapLocationClientOption(); //设置定位模式为AMapLocationMode.Hight_Accuracy,高精度模式。 // mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Battery_Saving); mLocationListener = new AMapLocationListener() { @Override public void onLocationChanged(AMapLocation aMapLocation) { if (aMapLocation != null) { if (listener != null) { listener.onLocationChanged(aMapLocation); } if (aMapLocation.getErrorCode() == 0) { //可在其中解析amapLocation获取相应内容。 Log.e("AMapSelectPointActivity", "aMapLocation=" + aMapLocation.getCity()); Log.e("AMapSelectPointActivity", "aMapLocation address=" + aMapLocation.getAddress()); } else { //定位失败时,可通过ErrCode(错误码)信息来确定失败的原因,errInfo是错误信息,详见错误码表。 Log.e("AmapError", "location Error, ErrCode:" + aMapLocation.getErrorCode() + ", errInfo:" + aMapLocation.getErrorInfo()); } } Log.e("AMapSelectPointActivity", "aMapLocation run onLocationChanged"); } }; //初始化定位 mLocationClient = new AMapLocationClient(getApplicationContext()); //设置定位回调监听 mLocationClient.setLocationListener(mLocationListener); mLocationClient.setLocationOption(mLocationOption);//设置模式 aMap.setOnCameraChangeListener(new AMap.OnCameraChangeListener() { @Override public void onCameraChange(CameraPosition cameraPosition) { LatLng target = cameraPosition.target; System.out.println(target.latitude + "jinjin------" + target.longitude); } @Override public void onCameraChangeFinish(CameraPosition cameraPosition) { LatLng target = cameraPosition.target; System.out.println("changeFinish="+target.latitude + "jinjin------" + target.longitude); LatLng ll = new LatLng(target.latitude,target.longitude); markerCenter.position(ll); searchAddressByLat(ll); // markerCenter.visible(true); // markerCenter.title("中心点"); // BitmapDescriptor bitmapDescriptor= BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(getResources(),R.mipmap.icon_nearby)); // markerCenter.icon(bitmapDescriptor); // aMap.addMarker(markerCenter); } }); } @Override protected void onDestroy() { super.onDestroy(); //在activity执行onDestroy时执行mMapView.onDestroy(),实现地图生命周期管理 mMapView.onDestroy(); mLocationClient.onDestroy(); } @Override protected void onResume() { super.onResume(); //在activity执行onResume时执行mMapView.onResume (),实现地图生命周期管理 mMapView.onResume(); //启动定位 mLocationClient.startLocation(); } @Override protected void onPause() { super.onPause(); //在activity执行onPause时执行mMapView.onPause (),实现地图生命周期管理 mMapView.onPause(); mLocationClient.stopLocation(); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); //在activity执行onSaveInstanceState时执行mMapView.onSaveInstanceState (outState),实现地图生命周期管理 mMapView.onSaveInstanceState(outState); } @Override public void activate(OnLocationChangedListener onLocationChangedListener) { Log.e("AMapSelectPointActivity", "activate is run"); listener = onLocationChangedListener; } @Override public void deactivate() {//高德地图位置监听 listener = null; } private void searchAddressByLat(final LatLng latLng){ geocodeSearch.setOnGeocodeSearchListener(new GeocodeSearch.OnGeocodeSearchListener() { @Override public void onRegeocodeSearched(RegeocodeResult result, int rCode) { if (rCode == 1000) { if (result != null && result.getRegeocodeAddress() != null && result.getRegeocodeAddress().getFormatAddress() != null) { String addressName = result.getRegeocodeAddress().getFormatAddress() + "附近"; aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15)); addressTxtView.setText(result.getRegeocodeAddress().getFormatAddress()); Toast.makeText(AMapSelectPointActivity.this, addressName,Toast.LENGTH_LONG).show(); } else { Toast.makeText(AMapSelectPointActivity.this, "未找到",Toast.LENGTH_LONG).show(); } } else { Toast.makeText(AMapSelectPointActivity.this, "失败",Toast.LENGTH_LONG).show(); } } @Override public void onGeocodeSearched(GeocodeResult geocodeResult, int i) { } }); LatLonPoint point = new LatLonPoint(latLng.latitude,latLng.longitude); RegeocodeQuery query = new RegeocodeQuery(point, 200,GeocodeSearch.AMAP); geocodeSearch.getFromLocationAsyn(query); } }

2016年12月15日 · 3 分钟 · 天边的星星

在Android Studio中有六种依赖

Compile,Provided,APK,Test compile,Debug compile,Release compile Compile compile是对所有的build type以及favlors都会参与编译并且打包到最终的apk文件中。 Provided Provided是对所有的build type以及favlors只在编译时使用,类似eclipse中的external-libs,只参与编译,不打包到最终apk。 APK 只会打包到apk文件中,而不参与编译,所以不能再代码中直接调用jar中的类或方法,否则在编译时会报错 Test compile Test compile 仅仅是针对单元测试代码的编译编译以及最终打包测试apk时有效,而对正常的debug或者release apk包不起作用。 Debug compile Debug compile 仅仅针对debug模式的编译和最终的debug apk打包。 Release compile Release compile 仅仅针对Release 模式的编译和最终的Release apk打包。 转自:http://www.cnblogs.com/kangyi/p/4449857.html [AndroidStudio中多个Module依赖同一个jar的解决方案](http://blog.csdn.net/u013134391/article/details/51538511) **方案****:** 将任意一个Module中的jar依赖为compile files(‘your jar name’),其他需要依赖的地方改为provided files(‘your jar name’)并且删除compile fileTree(include: [‘*.jar’], dir: ‘libs)。即可 下面详细介绍为什么这样做以及案例 **案例介绍** 如 环信Module和自己app的Module都要用到定位sdk **1、**在自己app的gradle中以compile引入如: compile files(‘libs/AMap_Location_V2.4.1_20160414.jar’) **2、**在环信的Module的gradle中以provided的方式引入如: provided files(‘libs/AMap_Location_V2.4.1_20160414.jar’) **3、**而且环信的gradle中不能存在compile fileTree(include: [‘*.jar’], dir: ‘libs’) ==========================分割线================================= AndroidStudio中Module相当于Eclispe中的Library,这里不做过多介绍 多个Module依赖同一个jar,直接把jar放入对应需要的Module会导致编译报类冲突 这里就要讲一讲AndroidStudio中的依赖的几种方式 compile compile是对所有的build type以及favlors都会参与编译并且打包到最终的apk文件中。 Provided Provided是对所有的build type以及favlors只在编译时使用,类似eclipse中的external-libs,只参与编译,不打包到最终apk。 APK 只会打包到apk文件中,而不参与编译,所以不能再代码中直接调用jar中的类或方法,否则在编译时会报错 Test compile Test compile 仅仅是针对单元[测试](http://lib.csdn.net/base/softwaretest)代码的编译编译以及最终打包测试apk时有效,而对正常的debug或者release apk包不起作用。 Debug compile Debug compile 仅仅针对debug模式的编译和最终的debug apk打包 Release compile Release compile 仅仅针对Release 模式的编译和最终的Release apk打包。 我们需要用的是Provided,这样在写代码的时候可以在Module中正常使用jar中的类,但是要有一个Module以compile的方式依赖这个jar,这样编译的时候只有一个jar编译进apk。 注:使用Provided必须删除compile fileTree(include: [‘*.jar’], dir: ‘libs’) 不然lib下的jar均按照compile方式引入到Module 搞定!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 转自:http://blog.csdn.net/u013134391/article/details/51538511

2016年12月8日 · 1 分钟 · 天边的星星

Android插件化开发之用DexClassLoader加载未安装的APK来实现app切换背景皮肤

第一步、先制做一个有我们需要的图片资源的APK 如下图,这里有个about_log.png,我们需要生成apk文件。 生成的apk文件如果你不到项目的文件夹里面去取apk,想通过命令放到手机里面去可以快速用下面命令 1)、在手机里面通过包名找到apk路径,一定不要忘记有 -f - adb shell pm list package -f | grep com.example.testclassloader 得到如下结果 - package:/data/app/com.example.testclassloader-2/<span class="attribute">base.apk</span>=<span class="attribute-value">com</span>.example.testclassloader 2)、把base.apk拉到本地然后改名字,命令如下 - adb shell pull /data/app/com.example.testclassloader-2/base.apk testClassLoader.apk 3)、把testClassLoader.apk放到手机里面去,命令如下 - adb shell push testClassLoader.apk /sdcard/ 4)、去手机文件管理器里面找看是否有testClassLoader.apk文件 ...

2016年11月23日 · 5 分钟 · 天边的星星

AS中Git与GitHub的使用入门

一直想把自己的写的开源小项目放到github中,这两天才花时间来学学Git。遇到些问题,百度了很多才解决。跟SVN一样,值得写一篇总结记录下,虽然上资源很多,但作为入门,自己遇到的写出来完全不一样。 一、 Git与GitHub的简单介绍 Git是一个开源的分布式版本控制工具。 GitHub是一个使用Git作为版本控制的项目托管平台,它是一个网站。 详细请参考:http://www.cnblogs.com/cocowool/archive/2012/02/17/2356125.html 二、 Git的安装 下载地址:https://git-scm.com/download/win 或 https://git-for-windows.github.io/ 安装时,全部默认选择即可。 三、 AS中配置Git与GitHub 1. Git的配置 在Settings设置中。 Path to Git executable: 【Git安装后的路径】 然后“Test”测试一下,成功才可以。 2. GitHub的配置 Host: github.com Login: 【你的github用户名】 Password: 【github登录密码】 填好后,也进行“Test”测试一下,同样成功才可以。 测试完后按确定,会提示你是否设置密码,看个人需求。 四、 上传代码到GitHub 1. 创建GitHub仓库 在Github上创建一个仓库: 创建好后,将是这个样子,里面包括一个.gitignore忽略配置文件和一个README.md git地址如下: 2. 创建Git本地仓库 选择工程 —— VCS —— …… 此时,VCS的5个图标显示出来了,且要提交的文件名都是暗红色 3. 把工程add添加到仓库 选择工程 —— 右键 —— Git —— Add Add后待提交的文件名是绿色 4. commit提交 CommitMessage:填入提交说明信息。主要用于说明你做了哪些修改。 按Commit提交即可。 注:我每次都无法提交,commit后,进度对话框走到一半就立马消失了。解决办法见下面常见问题的“无法commit”。 提交后的文件颜色是灰白色。修改过的文件时淡蓝色 5. push推送到GitHub Commit后会自动弹出Push推送窗口,点“Define remote”。 Name:默认origin URL:就是github的网页地址,上面已提供获取方法 ...

2016年11月22日 · 1 分钟 · 天边的星星