今天,在Q群中有网友(@广州-包晴天)发出了网上的一个相对经典的问题,问题具体见下图. 本来是无意写此文的,但群里多个网友热情不好推却,于是,撰此文予以分析. 从这个问题的陈述中,我们发现,提问者明显对Android中的几个基本概念在理解上是存在误区的(或直接称之为理解错误).且这种误区,我发现是较为广泛的存在于不少Android开发心中的. 理解误区主要体现在对以下几个概念没有区分清: 1,Activity的onDestory回调方法: 2,Activity的销毁: 3,Activity的内存…
Context的作用:用来访问全局信息的接口,通过Context进行资源的访问. 1.Context获取字符串资源: public class MainActivity extends AppCompatActivity { private TextView tv; @Override    protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);        tv = ne…
AIDL(Android Interface Definition Language)--安卓接口定义语言 一.startService/stopService 1.同一个应用程序启动Service: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); startService(new Int…
android Layout_weight的理解 SDK中的解释: Indicates how much of the extra space in the LinearLayout will be allocated to the view associated with these LayoutParams. Specify 0 if the view should not be stretched. Otherwise the extra pixels will be pro-rated …
跨应用绑定Service并通信: 1.(StartServiceFromAnotherApp)AIDL文件中新增接口: void setData(String data); AppService文件中实现接口: public IBinder onBind(Intent intent) { return new IAppServiceRomoteBinder.Stub() { @Override public void basicTypes(int anInt, long aLong, boole…
在使用到9.png的布局上面添加 android:padding="0dip" 比如 <LinearLayout            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:layout_margin="20dp"            android:l…
Context概念 当我们访问当前应用的资源,启动一个新的activity的时候都需要提供Context. Context是一个抽象基类,我们通过它访问当前包的资源(getResources.getAssets)和启动其他组件(Activity.Service.Broadcast)以及得到各种服务(getSystemService),当然,通过Context能得到的不仅仅只有上述这些内容.对Context的理解可以来说:Context提供了一个应用的运行环境,在Context的大环境里,应用才可…
编码中的setCharacterEncoding 理解 1.pageEncoding="UTF-8"的作用是设置JSP编译成Servlet时使用的编码. 2.contentType="text/html;charset=UTF-8"的作用是指定对服务器响应进行重新编码的编码. 3.request.setCharacterEncoding("UTF-8")的作用是设置对客户端请求进行重新编码的编码. 4.response.setCharacterE…
Fence是一种同步机制,在Android里主要用于图形系统中GraphicBuffer的同步.那它和已有同步机制相比有什么特点呢?它主要被用来处理跨硬件的情况.尤其是CPU.GPU和HWC之间的同步,另外它还能够用于多个时间点之间的同步.GPU编程和纯CPU编程一个非常大的不同是它是异步的.也就是说当我们调用GL command返回时这条命令并不一定完毕了.仅仅是把这个命令放在本地的command buffer里.详细什么时候这条GL command被真正运行完毕CPU是不知道的,除非CPU使…
在Android应用开发中,有的类里面需要声明一个Context的成员变量,然后还需要在该类的构造函数中加上this.context=context;这行代码.为什么要这么写呢?不写不行么? 先看下面这个例子,这是我在百度空间看到的: Button button=new Button(this); 括号里的this当然就是本质上Context,其指向的就是当前的Activity,原因形象点说就是Button为了能相应各种操作,记得让Android系统知道自己是属于哪个Activity,这个信息是…