正常的 Intent 传值的方法1234Intent intent = new Intent(FirstActivity.this, SecondActivity.class);intent.putExtra("string_data","hello");intent.putExtra("int_data",100);startActivity(intent);
在 SecondActivity 众通过 getIntent 获取值12getIntent().getStringExtra("string_data&quo...
在 Activity 中创建
在 BoardCast 中创建
在 Service 中创建
使用
管理 Notification
1NotificationManager manager = (NotificationManager) Context.getSystemService(Context.NOTIFICATION_SERVICE);
构造 Notification 对象通过 NotificationCompat.Builder构造
1Notification notification = new NotificationCompat.Builder(context).bu...
常用控制方法Android 通过控制播放器的状态的方式来控制媒体文件的播放,其中:
setDataSource() 设置要播放的音频文件位置prepare()和 prepareAsync() 完成准备工作提供了同步和异步两种方式设置播放器进入prepare状态,需要注意的是,如果MediaPlayer实例是由create方法创建的,那么第一次启动播放前不需要再调用prepare()了,因为create方法里已经调用过了。start()是真正启动文件播放的方法,pause() 暂停播放stop() 停止播放seekTo() 是定位方法,可以让播放器从指定的位置开始播放,需要注意的是该方法是...
基本概念用法两种:
使用现有的ContentProvider来读取和操作相应程序中的数据
创建自己的内容提供器给我们的程序的数据提供外部访问接口
ContentResolver 使用方法ContentResolver resolver = Context.getContentResolver();resolver.insert //增resolver.delete //删resolver.update //改resolver.query //查
参数为 内容URI :content://com.example.app.provider/table1不过得先解析为 URI 对象:Ur...
基本概念
Message线程之间传递的载体.what .arg1 .arg2 字段可以携带整型数据
Handler用于发送和处理 MessageHandler.sendMessage()Handler.handleMessage()
MessageQueue存放所有通过 Handler 发送的消息, 等待被处理每个线程只会有一个 MessageQueue
LooperLooper 是每个线程 MessageQueue 的管家.Looper.loop() 后, 会进入循环, 当发现 MessageQueue 中存在消息, 就会取出, 并传递到 Handler.handleMessa...
动态注册MainActivity.java12345678910111213141516171819202122232425262728293031323334353637383940 private IntentFilter intentFilter; private NetworkChangeReceiver networkChangeReceiver; // 内部类 onCreate { intentFilter = new IntentFilter(); // 添加 Action intentF...
LitePal 基本概念LitePal 是开源的 Android 数据库框架, 采用了 对象关系映射 ORM 模式 .封装了常用数据库功能
ORM(对象关系映射) 指的是 面向对象语言 和 关系型数据库 之间建立一种映射关系.
使用方法配置123dependencies { compile 'org.litepal.android:core:2.0.0'}
1android:name="org.litepal.LitePalApplication"
litepal.xml
1Connector.ge...
WebView 使用 SOPactivity.xml1234567891011<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <WebView android:id="@+id/web_view" ...
写123456789101112131415161718192021222324/** * 文件名 为 data * @param inputText */private void save(String inputText) { FileOutputStream out = null; BufferedWriter writer = null; try { out = openFileOutput("data", Context.MODE_PRIVATE); writer = new BufferedWriter(new...
简介通过键值对的方式进行存储. 保存为 xml 文件value - key
存储
获取 SharedPreferences 对象 SharedPreferences.Editor editor = getSharedPreferences(“data”, MODE_PRIVATE).edit();
editor.putString(“name”, “Tom”);
editor.apply();123456// 通过 getSharedPreferences() 方法指定 SharedPreferences 文件名为 dataSharedPreferences.Editor editor ...