共 31 篇文章 |
|
这种方式可以结合第一种方式来实现特定情形下的应用退出,这种方式的一个最显著地特点就是在启动Activity的Intent中加入Intent.FLAG_ACTIVITY_CLEAR_TOP标记,这个标记的主要作用就是会在task中将你启动的哪个Activity上面的Activity全部销毁掉,这适合于将退出操作放置在应用的第一个Activity中,其他Activity通过使用Intent.FLAG_ACTIVITY_CL... 阅821 转12 评0 公众公开 12-02-20 16:35 |
在工作过程序中遇到一个需要完全关闭应用程序的问题,在网络上找了一大堆的文章,每篇都是用System.exit(0)或者android.os.Process.killProcess(android.os.Process.myPid())这两种方法,但是我试过了,System.exit(0)这个根本不行,而android.os.Process.killProcess(android.os.Process.myPid())这个只能关闭当前的Activity,也就是对于一个... 阅3473 转13 评0 公众公开 12-02-20 16:29 |
扩展 Service 类 (Extending the Service class)启动一个服务 (Starting a Service)// indicates whether onRebind should be used @Override public void onCreate() { // The service is being created } @Override public int onStartCommand(Intent intent, int flags, int startId) { // The ... 阅405 转5 评0 公众公开 12-02-19 17:07 |
service的onstartcommand函数。原文地址:Android中Service类onStartCommand的返回值问题作者:阿涵Android开发的过程中,每次调用startService(Intent)的时候,都会调用该Service对象的onStartCommand(Intent,int,int)方法,然后在onStartCommand方法中做一些处理。从Android官方文档中,我们知道onStartCommand有4种返回值:START_STICKY:如... 阅10561 转4 评0 公众公开 12-02-19 17:06 |
Android怎么让一个service开机自动启动Java代码 时间过得真快,开学的日子也越来越近了,前段时间都是忙于上一届学员的工作,今天终于有时间坐下来静静的整理上一届授课的方面的知识点了,接下来的日子我会坚持把授课中的关于android方面的知识做进一步细化的总结,也希望能给将要进入3G行业的学员们提供更多的学习帮助! 阅4165 转16 评0 公众公开 12-02-19 13:10 |
发送一个广播,所以监听该广播的广播接收者都可以监听到改广播。4 ,能截断广播的继续传播,高级别的广播收到该广播后,可以决定把该钟广播是否截断掉。这个方法可以截获由 sendOrderedBroadcast () 发送来的 广播,让其它广播接收者无法收到这个广播。如果广播接收者是目前处理的一个宿主的广播的初始值,将返回 true , - 也就是说,这个值... 阅868 转4 评0 公众公开 12-02-18 18:21 |
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <Button android:id="@+id/btnBroadcast" and... 阅2531 转25 评0 公众公开 12-02-18 18:07 |
1 @Override 2 protected void onResume() { 3 // TODO Auto-generated method stub 4 5 myReceiver = new MyReceiver();@Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub System.out.println("intent = " + intent);25 }26 27 @Override28 protected void onResume... 阅219 转2 评0 公众公开 12-02-18 17:42 |
2、Looper.myLooper(); //获得当前的LooperLooper.getMainLooper () //获得UI线程的Lopper3、Handle的初始化函数(构造函数),如果没有参数,那么他就默认使用的是当前的Looper,如果有Looper参数,就是用对应的线程的Looper。Looper looper = Looper.public MyHandler(Looper looper){3.2 handler传递runnable对象还有另外一种用Handler来... 阅512 转3 评0 公众公开 12-02-17 16:09 |
前面提到Android系统的消息队列和消息循环都是针对具体线程的,一个线程可以存在(当然也可以不存在)一个消息队列和一个消息循环(Looper),特定线程的消息只能分发给本线程,不能进行跨线程,跨进程通讯。但是创建的工作线程默认是没有消息循环和消息队列的,如果想让该线程具有消息队列和消息循环,需要在线程中首先调用Looper.prepare()来... 阅92 转1 评0 公众公开 12-02-17 16:04 |