+网络图片浏览
摘要:1、权限2、代码//这次的HttpURLConnection仅针对Http连接,效率胜于URLConnection。 String uriPic =et.getText().toString(); URL imageUrl = null; Bitma...
阅读全文
用webview自定义网址
摘要:代码wv=(WebView)this.findViewById(R.id.wv); wv.loadData( ""+""+"www.baidu.com"+""+"", "text/html", "utf-8");
阅读全文
使用Uri和WebView打开网页
摘要:1、权限2、代码(1)String url = et.getText().toString();//获取网址 wv.loadUrl(url);//在WebView中加载网页(2)String url = et.getText().toString();//获取网址 Uri ur...
阅读全文
手机储存卡容量查询
摘要:if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {//判断存储卡是否插入 File path=Environment.getExternalStorageDirectory();...
阅读全文
查看手机电量
摘要:1、创建BroadcastReceiver对象,重写onReceive()方法首先获取Action事件,当判断该事件为Intent.ACTION_BATTERY_CHANGED时,获取手机当前电量和总电量BroadcastReceiver br=new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub String s=intent.getAction(); if(Intent.A...
阅读全文
提醒用户收到短信
摘要:1、权限和创建广播 2、代码public class MyReceiver extends BroadcastReceiver{ @SuppressWarnings("deprecation") public void onReceive(Context context,Intent intent){ if(intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")){ StringBuilder sb=new StringBuilder(); Bundle bundle...
阅读全文
手机屏幕更改
摘要:1、权限 2、final Display defaultDisplay=getWindow().getWindowManager().getDefaultDisplay();//获取手机的分辨率setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); screenHeight=defaultDisplay.getHeight();//获取手机分辨率高度 screenWidth=defaultDisplay.getWidth();//获取手机分辨率宽度 tv.setText(sc...
阅读全文
查看手机信息和SIM卡信息
摘要:1、取得权限2、获得信息 if(tm.getLine1Number()!=null){ list.add(tm.getLine1Number()); }else{list.add("无法获取您的电话号码");} if(!tm.getNetworkCountryIso().equals("")){ list.add(tm.getNetworkCountryIso()); }else{list.add("无法获取您的电信网络国别");} if(!tm.getNetworkOperator().equals(""...
阅读全文
还原和设置手机桌面背景
摘要:1、申请权限 2、调用clearWallpaper还原为默认桌面 MainActivity.this.clearWallpaper();3、设置桌面InputStream is;Resources resource=getBaseContext().getResources(); is=resource.openRawResource(R.drawable.wall);MainActivity.this.setWallpaper(is);4、取得当前桌面getWallpaper()
阅读全文
wifi的开与关
摘要:1、在manifest申请权限 2、相关操作WifiManager mWifi=(WifiManager)this.getSystemService(Context.WIFI_SERVICE);//创建对象if(mWifi.isWifiEnabled())//若WIFI状态为已打开if(mWifi.setWifiEnabled(false))//关闭WIFIswitch(mWifi.getWifiState()) { case WifiManager.WIFI_STATE_ENABLING://WIFI在启动过程中,将无法关闭 bre...
阅读全文
带图片的Toast
摘要:Toast toast=Toast.makeText(MainActivity.this, "手机在振动", Toast.LENGTH_SHORT);View textView=toast.getView(); LinearLayout ll=new LinearLayout(MainActivity.this);ImageView iv=new ImageView(MainActivity.this);ll.setOrientation(LinearLayout.HORIZONTAL);iv.setImageResource(R.drawable.ic_launcher)
阅读全文
关于手机振动
摘要:首先要在manifest中申请权限,,然后定义 Vibrator vb,vb.vibrate(new long[]{100,10,100,10000},-1);//设置手机振动,四个参数,前三个为设定振动的大小,将数值改成一大一小就可以感觉到振动的差异,最后一个值repeat为振动的时间,repeat=-1表示只震动一轮,repeat=0会一直振动下去
阅读全文