intent

对于android.intent.action.MAIN和android.intent.category.LAUNCHER的理解

两盒软妹~` 提交于 2020-01-21 05:35:54
当我们使用Android Studio创建一个工程并生成一个Activity时,经常可以在清单文件中看到如下的代码: <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> 如果我们创建第二个Activity的话,标签里面默是没有action和category的,那么这里的android.intent.action.MAIN和android.intent.category.LAUNCHER有什么作用呢? 通过查阅API文档,了解到它们的作用如下: android.intent.action.MAIN:决定应用的入口Activity,也就是我们启动应用时首先显示哪一个Activity。 android.intent.category.LAUNCHER:表示activity应该被列入系统的启动器(launcher)(允许用户启动它)。Launcher是安卓系统中的桌面启动器,是桌面UI的统称。 action和category都是Intent的组成部分

Application Fundamentals-Components

流过昼夜 提交于 2020-01-20 15:52:44
Android applications are written in the Java programming language. The Android SDK tools compile the code—along with any data and resource files—into an Android package , an archive file with an .apk suffix. All the code in a single .apk file is considered to be one application and is the file that Android-powered devices use to install the application. Once installed on a device, each Android application lives in its own security sandbox: The Android operating system is a multi-user Linux system in which each application is a different user. By default, the system assigns each application a

Android-- Intent.Action(1)

▼魔方 西西 提交于 2020-01-20 10:20:43
1 Intent.ACTION_MAIN String: android.intent.action.MAIN 标识Activity为一个程序的开始。比较常用。 Input:nothing Output:nothing 例如: 1 < activity android:name =".Main" android:label ="@string/app_name" > 2 < intent-filter > 3 < action android:name ="android.intent.action.MAIN" /> 4 < category android:name ="android.intent.category.LAUNCHER" /> 5 </ intent-filter > 6 </ activity > 2 Intent.Action_CALL Stirng: android.intent.action.CALL 呼叫指定的电话号码。 Input:电话号码。数据格式为:tel:+phone number Output:Nothing Intent intent = new Intent(); intent.setAction(Intent.ACTION_CALL); intent.setData(Uri.parse( " tel:1320010001 " );

Android9.0保活后台service

南楼画角 提交于 2020-01-19 13:57:35
Android8.0之后Service变为后台后很开就会被杀死。因此要采取一定的措施进行保活。 启动service: Intent i=new Intent(context,TestIntentService.class); if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.O){ context.startForegroundService(i); }else{ context.startService(i); } Service类为: package com.example.myapplicationww; import android.app.IntentService; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import

android拨打电话

帅比萌擦擦* 提交于 2020-01-19 11:54:57
1、要使用Android系统中的电话拨号功能,首先必须在AndroidManifest.xml功能清单中加入允许拨打电话的权限: <uses-permission android:name="android.permission.CALL_PHONE" /> // 允许拨打电话权限 2、 进行拨打电话的代码: a 、调用Android系统的拨号界面,但不发起呼叫,用户按下拨号键才会进行呼叫 @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button callBut = (Button)findViewById(R.id.callBut); callBut.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { 黄色必须有 Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse( " tel:13800138000")); startActivity(intent); } }); } b、

Android拨打电话

别来无恙 提交于 2020-01-19 11:54:17
1、要使用Android系统中的电话拨号功能,首先必须在AndroidManifest.xml功能清单中加入允许拨打电话的权限: <uses-permission android:name="android.permission.CALL_PHONE" /> // 允许拨打电话权限 2、进行拨打电话的代码: a、调用Android系统的拨号界面,但不发起呼叫,用户按下拨号键才会进行呼叫 @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button callBut = (Button)findViewById(R.id.callBut); callBut.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { 黄色必须有 Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse( "tel:13800138000")); startActivity(intent); } }); } b、直接拨号发起呼叫

Android唤醒 传参

我与影子孤独终老i 提交于 2020-01-19 03:06:43
App唤醒其他App传参问题 基本使用方法 1.urlschema 隐式 调用方: webview.loadUrl("lf-open://open/lf?username=121&pwd=456"); 被唤醒方: Uri uri = getIntent().getData(); if (uri != null) { String username = uri.getQueryParameter("username"); String pwd = uri.getQueryParameter("pwd"); Log.d("lf", username + "," + pwd); } <activity android:name=".SettingActivity" android:launchMode="singleTask" android:theme="@style/Theme.AppCompat"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> <action android:name="android

HBuilder第三方插件开发(Android平台openinstall集成)

只谈情不闲聊 提交于 2020-01-18 05:39:00
开发插件 编写 Android 原生代码 下载 openinstall SDK 并将 jar 包拷贝到项目的 libs 目录。创建一个 package ,如 com.wenkiwu.hbuilder.openinstall ;在包中新建一个类继承自 StandardFeature ,然后对应openinstall的接口定义相应的功能方法。完整代码如下: package com.wenkiwu.hbuilder.openinstall; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.text.TextUtils; import android.util.Log; import com.fm.openinstall.OpenInstall; import com.fm.openinstall.listener.AppInstallAdapter; import com.fm.openinstall.listener.AppWakeUpAdapter; import com.fm.openinstall.model.AppData; import org.json

安卓开发记录(3)---仿滴滴做一个点击按钮,弹出侧边菜单

為{幸葍}努か 提交于 2020-01-17 23:53:40
前言: 制作一个类似于滴滴点击左上角头像,弹出一个侧边菜单其实特别简单。而且不需要导入任何包,直接复制几行代码即可。如果您想尝试一下,请自行new一个模板叫:Navigation Drawer Activity。自行复制代码导入项目。 1.纯净版demo 一定要看清楚使用的是v4包的项目还是AndroidX的项目,因为他们所对应的xml tag不一样。请按照自己项目,修改对应tag < ! -- v4项目头尾文件 < android . support . v4 . widget . DrawerLayout < / android . support . v4 . widget . DrawerLayout > -- > < ! -- Androidx项目头尾文件 < androidx . drawerlayout . widget . DrawerLayout < / androidx . drawerlayout . widget . DrawerLayout > -- > xml: < ? xml version = "1.0" encoding = "utf-8" ? > < android . support . v4 . widget . DrawerLayout xmlns : android = "http://schemas.android.com/apk

Kotlin-Android开发之透彻理解EventBus的MAIN、POSTING、BACKGROUND、ASYNC,4种线程模式

匆匆过客 提交于 2020-01-17 03:55:35
前言:很多人写项目都会用到EventBus,可以说解决了很多麻烦的事情,区区几行代码,就能解决四大组件的通信,异步线程和主线程之间的通信。这次主要介绍EventBus的4种线程模式:ThreadMode.MAIN(常用)、ThreadMode.POSTING、ThreadMode.BACKGROUND、ThreadMode.ASYNC EventBus的简单用法 1.添加eventbus3.1.1依赖 implementation 'org.greenrobot:eventbus:3.1.1' 2.在MainActivy中接收SecondActivity中EventBus发送的信息(注意:在onCreate()里面注册,在onDestory()中注销) class MainActivity : AppCompatActivity() { private lateinit var button: Button override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) EventBus.getDefault().register(this) //注册EventBus button =