设置里面的很多信息都是保存在数据库中的,当我们改变gps等设置时,会改变数据库里面的值, 我们可以用内容观察者对其进行监听,然后做出相应处理,这里贴出关键代码 private final ContentObserver mGpsMonitor = new ContentObserver(null) { @Override public void onChange(boolean change) {
上一篇提到用内容观察者通过来监听数据库变化获取GPS状态,其实在GPS状态或模式改变时, 会发出相应的广播LocationManager.MODE_CHANGED_ACTION,LocationManager.PROVIDERS_CHANGED_ACTION 这里贴出关键代码: ////注册广播 IntentFilter filter = new IntentFilter(); filter.ad
/** 获取存储卡路径 */ File sdcardDir=Environment.getExternalStorageDirectory(); /** StatFs 看文件系统空间使用情况 */ StatFs statFs=new StatFs(sdcardDir.getPath()); /** Block 的 size*/ Long blockSize=statFs.getBlockSize(
public class CustomDialog { private AlertDialog.Builder builder; private Context context; public CustomDialog(Context context) { // TODO Auto-generated constructor stub this.context = context; } publi
因为external storage可能是不可用的,比如遇到SD卡被拔出等情况时。因此在访问之前应对其可用性进行检查。我们可以通过执 行 getExternalStorageState()来查询external storage的状态。若返回状态为MEDIA_MOUNTED, 则 可以读写。 /* Checks if external storage is available for read an
if(strpos($_SERVER['HTTP_USER_AGENT'], 'Android')){ echo 'systerm is Android'; }else{ echo 'systerm is other';
AndroidManifest.xml
AndroidManifest.xml
countdowntimerdemo; import android.os.CountDownTimer; import android.util.Log; import android.widget.Button; /**
import android.app.Activity; import android.util.DisplayMetrics; public class Screen { private Screen(){
import android.content.Context; import android.util.TypedValue; //常用单位转换的辅助类 public class DensityUtils
android开发中实现整个屏幕截图,首先通过activity对象的getwindow()方法获得整个屏幕的window对象,再通过整个屏幕的window对象的getDecorView()方法获得整个
net/zhaokaiqiang1992 在前面的两篇文章中,我们介绍了DES算法,3DES算法以及他们的Android程序实现,并研究了如何才能实现不同平台下加密算法的一致性。不过话说 起来,DES算法是在197
前言 App判断用户是否联网是很普遍的需求,实现思路大概有下面几种 利用Android自带的ConnectivityManager类 有时候连上了wifi,但这个wifi是上不了网的,我们可以通过ping
.LOCATION_SERVICE); if (alm.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER)) { return
主界面(发送数据的Activity) class ButtonListener implements android.view.View.OnClickListener{ @Override public void
java.util.LinkedList; /* * 基于Java LinkedList,实现Android大数据缓存策略 * 作者:Zhang Phil * 原文出处:http://blog.csdn
concurrent.RejectedExecutionException; import android.util.Log; /** * 批量图片下载类 无需与界面交互的下载类 * * @Description:
做几乎每一个Android应用开发,都少不了用到一个控件,那就是ListView,用于加载多条数据,并用一定的样式展示出来。但是为了性能问题(一 次性加载太多数据,比如100000条,耗费时间长,消耗
在用Android进行网络操作时,首先得判断网络是否连通,以下代码可以检测: public static boolean isNetworkAvailable(Context context){ ConnectivityManager