intent

Android零基础入门第80节:Intent 属性详解(下)

对着背影说爱祢 提交于 2019-11-27 07:44:36
上一期学习了Intent的前三个属性,本期接着学习其余四个属性,以及Android系统常用内置组件的启动。 四、Data和Type属性 Data属性通常用于向Action属性提供操作的数据。Data属性接受一个Uri对象,一个Uri 对象通常通过如下形式的字符串来表示: content://com.android.contacts/contacts/1 tel:123 Uri字符串总满足如下格式: scheme://host:port/path 例如上面给出的 content://com.android.contacts/contacts/l,其中 content 是 scheme 部分, com.android.contacts 是 host 部分,port 部分被省略了,/contacts/1 是 path 部分。 Type属性用于指定该Data属性所指定Uri对应的MIME类型,这种MIME类型可以是任何自定义的MIME类型,只要符合abc/xyz格式的字符串即可。 Data属性与Type属性的关系比较微妙,这两个属性会相互覆盖,例如: 如果为Intent先设置Data属性,后设置Type属性,那么Type属性将会覆盖Data属性。 如果为Intent先设置Type属性,后设置Data属性,那么Data属性将会覆盖Type属性。 如果希望Intent既有Data属性

71道Android开发面试题

情到浓时终转凉″ 提交于 2019-11-27 07:14:32
文章转载自: http://www.pythonheidong.com/blog/article/3310/ 注:本文来自“安卓巴士” Android面试题 1. 下列哪些语句关于内存回收的说明是正确的? (b ) A、 程序员必须创建一个线程来释放内存 B、 内存回收程序负责释放无用内存 C、 内存回收程序允许程序员直接释放内存 D、 内存回收程序可以在指定的时间释放内存对象 2. 下面异常是属于Runtime Exception 的是(abcd)(多选) A、 ArithmeticException B、 IllegalArgumentException C、 NullPointerException D、 BufferUnderflowException 3. Math.round(11.5)等于多少(). Math.round(-11.5)等于多少(c). c A、11 ,-11 B、11 ,-12 C、12 ,-11 D、12 ,-12 4. 下列程序段的输出结果是:(b ) void complicatedexpression_r(){ int x=20, y=30; boolean b; b=x>50&&y>60||x>50&&y<-60||x<-50&&y>60||x<-50&&y<-60; System.out.println(b); } A、true B

adb命令使用

半世苍凉 提交于 2019-11-27 06:55:22
摘取简书中作者: anly_jun 中的内容 1, adb简介 adb全名Andorid Debug Bridge. 顾名思义, 这是一个Debug工具. 然而, 为何称之为Bridge呢? 因为adb是一个标准的CS结构的工具, 是要连接开发电脑和你的调试手机的.包含如下几个部分: Client端, 运行在开发机器中, 即你的开发PC机. 用来发送adb命令. Deamon守护进程, 运行在调试设备中, 即的调试手机或模拟器. Server端, 作为一个后台进程运行在开发机器中, 即你的开发PC机. 用来管理PC中的Client端和手机的Deamon之间的通信. 2, 常用用法 2.1 adb devices 列举当前连接的调试设备 $ adb devices List of devices attached DU2SSE1467010378 device 2.2 adb logcat 打印log信息 指令 说明 备注 adb logcat 打印log / adb logcat -c 清除手机的log buffer 有些手机权限控制, 不支持. adb logcat -b <buffer> 打印指定buffer的log信息 buffer有: main(主log区,默认), events(事件相关的log), radio(射频, telephony相关的log) adb

张萌&韩墨羽——SurfaceView使用

走远了吗. 提交于 2019-11-27 05:58:44
SurfaceView使用 要求 调用系统相机实施自拍并保存到本地 调用系统摄像机,录制音视频并保存到本地 调用系统浏览器,完成搜索java 打开蓝牙,显示搜索到附近的蓝牙列表 截图蓝牙列表,保存到本地 获取本机蓝牙信息,保存到txt 实现关闭蓝牙 实现一键拨打10086 效果 代码 package com.example.uri_use; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.core.content.FileProvider; import android.Manifest; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter;

Android中TabWidget的应用

 ̄綄美尐妖づ 提交于 2019-11-27 05:40:09
步骤 1.建立两个Activity,作为tab内容 (我这里是OneActivity、TestActivity) public class OneActivity extends Activity { public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; TextView textview = new TextView ( this ) ; textview. setText ( "This is the Artists tab" ) ; setContentView ( textview ) ; } } 2.在layout文件夹中建立tab.xml用于怎样显示tab页面 注意:TabHost ,TabWidget ,FrameLayout的ID必须分别为@android:id/tabhost,@android:id/tabs,@android:id/tabcontent 另外还要注意一下android:layout_width宽度和android:layout_height高度的取值,还要LinearLayout的android:orientation=”vertical”(LinearLayout默认是横向的

bindService和AIDL的简单应用例子

隐身守侯 提交于 2019-11-27 03:37:34
1.Service不是一个单独的进程,它和它的应用程序在同一个进程中 2.Service不是一个线程,这样就意味着我们应该避免在Service中进行耗时操作 话不多说,我们直接上代码,是bingService启动service的,startService暂时先不上了。。。。。通过bindservice可以使service和avtivity通信。。。 首先创建一个TestServiceOne继承Service; public class TestServiceOne extends Service { private static final String TAG = "TestServiceOne"; private int count; private boolean quit; private MyBinder binder = new MyBinder(); public class MyBinder extends Binder{ public int getCount(){ return count; } } @Override public IBinder onBind(Intent intent) { Log.i(TAG, "onBind方法被调用!"); return binder; } @Override public void onCreate(){ super

Service与Activity通信

霸气de小男生 提交于 2019-11-27 03:29:01
1、怎样在启动一个Service时向它传递数据   关键点:Intent传值,onStartCommand()接收。   2、怎样向运行的Service中同步数据   关键点:通过onBind()获取Service实例,然后再调用Binder中的相关方法。   3、怎样侦听Service中数据变化   关键点:通过回调函数达到目的。 一、准备Service   先贴出Service的详细代码,然后再慢慢分析 public class MyService extends Service { private String data = "默认消息"; private boolean serviceRunning = false; // 必须实现的方法,用于返回Binder对象 @Override public IBinder onBind(Intent intent) { System.out.println("--onBind()--"); return new MyBinder(); } public class MyBinder extends Binder { MyService getService() { return MyService.this; } public void setData(String data) { MyService.this.data =

简单的实现网路请求

你说的曾经没有我的故事 提交于 2019-11-26 23:57:43
动画 public class MainActivity extends AppCompatActivity { private ImageView img; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Intent intent=new Intent(MainActivity.this,Main2Activity.class); // startActivity(intent); img = (ImageView) findViewById(R.id.img); Animation animation=new AlphaAnimation(0.1f,1.0f); animation.setDuration(5000); img.startAnimation(animation); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { }

Android插件化——Hook技术

为君一笑 提交于 2019-11-26 23:54:18
1、Hook技术之动态代理 Hook技术的基础和必备技术是动态代理,关于动态代理的使用和原理参见 Java动态代理 2、Binder Hook(Hook 系统服务) 2.1、系统获取服务的原理 ContextImpl.getSystemService(String name) @Override public Object getSystemService ( String name ) { return SystemServiceRegistry . getSystemService ( this , name ) ; } public static Object getSystemService ( ContextImpl ctx , String name ) { //1、从注册的SYSTEM_SERVICE_FETCHERS中根据名称获取ServiceFetcher ServiceFetcher < ? > fetcher = SYSTEM_SERVICE_FETCHERS . get ( name ) ; return fetcher != null ? fetcher . getService ( ctx ) : null ; //2、ServiceFetcher中创建服务 } 在使用系统服务时会直接调用Context的getSystemService()

Android响应点击事件页面跳转

这一生的挚爱 提交于 2019-11-26 23:44:23
这是我Android学习的第一天,第一堂课的作业是写两个button,分别实现点击显示hello world 和图片消息。 实现代码如下: activity_main.xml: 1 <?xml version="1.0" encoding="utf-8"?> 2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:app="http://schemas.android.com/apk/res-auto" 4 xmlns:tools="http://schemas.android.com/tools" 5 android:layout_width="match_parent" 6 android:layout_height="match_parent" 7 tools:context="com.example.zhangqiongwen.homework1.MainActivity" 8 tools:layout_editor_absoluteY="81dp"> 9 10 <include layout="@layout/button"> 11 12 </include> 13 </RelativeLayout> button.xml: 1 <?xml version=