当前位置: 首页 > news >正文

重庆网站建设公司怎么做小程序api函数

重庆网站建设公司怎么做,小程序api函数,企业怎样选择域名做网站,门户网站开发合同Android 系统桌面 App —— Launcher 开发#xff08;1#xff09; Launcher简介 Launcher就是Android系统的桌面#xff0c;俗称“HomeScreen”也就是我们开机后看到的第一个App。launcher其实就是一个app#xff0c;它的作用是显示和管理手机上其他App。目前市场上有很…Android 系统桌面 App —— Launcher 开发1 Launcher简介 Launcher就是Android系统的桌面俗称“HomeScreen”也就是我们开机后看到的第一个App。launcher其实就是一个app它的作用是显示和管理手机上其他App。目前市场上有很多第三方的launcher应用比如“小米桌面”、“91桌面”等等 注册AndroidManifest 要让app作为Launcher需要在Manifest中添加两个category category android:nameandroid.intent.category.HOME/ category android:nameandroid.intent.category.DEFAULT/ 添加后的代码 activity android:name.MainActivityintent-filteraction android:nameandroid.intent.action.MAIN/category android:nameandroid.intent.category.HOME/category android:nameandroid.intent.category.DEFAULT/category android:nameandroid.intent.category.LAUNCHER//intent-filter /activity 此时安装此app之后点击Home键就会看到以下界面让你选择使用哪一个桌面应用 如果选择我们自己开发的 Launcher App就会启动 我们自己的桌面应用目前这个应用是空白的需要添加应用列表以及相应的点击事件。 注意普通的安卓手机都能看到另外一个界面但是像小米、华为这样的手机就不行。 使用PackageManager扫描所有app 编辑MainActivity public class MainActivity extends AppCompatActivity { ​Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);   //获取所有app设置adapterPackageManager pm getPackageManager();Intent mainIntent new Intent(Intent.ACTION_MAIN, null);mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);final ListResolveInfo activities pm.queryIntentActivities(mainIntent, 0);RecyclerView recyclerView findViewById(R.id.rv);AppAdapter adapter new AppAdapter(activities, this);recyclerView.setAdapter(adapter);recyclerView.setLayoutManager(new GridLayoutManager(this, 3));} } 我们在MainActivity中使用PackageManager的queryIntentActivities方法扫描出手机上已安装的所有app信息。 activity_main 布局代码 ?xml version1.0 encodingutf-8? androidx.constraintlayout.widget.ConstraintLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parenttools:context.MainActivity ​androidx.recyclerview.widget.RecyclerViewandroid:idid/rvAppsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parent / /androidx.constraintlayout.widget.ConstraintLayout 由于布局中使用了 RecyclerView记得导入 RecyclerView 库 implementation androidx.recyclerview:recyclerview:1.1.0 显示app信息添加点击事件 新建AppAdapter类 public class AppAdapter extends RecyclerView.AdapterAppAdapter.ViewHolder { ​private ListResolveInfo mList;private Context mContext; ​public AppAdapter(ListResolveInfo list, Context context) {this.mList list;this.mContext context;} ​NonNullOverridepublic AppAdapter.ViewHolder onCreateViewHolder(NonNull ViewGroup parent, int viewType) {View inflate LayoutInflater.from(mContext).inflate(R.layout.rv_item, parent, false);//作为一个view填充View view View.inflate(parent.getContext(), R.layout.rv_item, null);return new ViewHolder(view);} ​Overridepublic void onBindViewHolder(NonNull final AppAdapter.ViewHolder holder, final int position) {holder.mIcon.setImageDrawable(mList.get(position).loadIcon(mContext.getPackageManager()));holder.mTtile.setText(mList.get(position).loadLabel(mContext.getPackageManager()));holder.itemView.setOnClickListener(new View.OnClickListener() {Overridepublic void onClick(View v) {Intent launchIntent new Intent();launchIntent.setComponent(new ComponentName(mList.get(position).activityInfo.packageName,mList.get(position).activityInfo.name));mContext.startActivity(launchIntent);}});} ​Overridepublic int getItemCount() {return mList null ? 0 : mList.size();} ​public class ViewHolder extends RecyclerView.ViewHolder {private ImageView mIcon;private TextView mTtile; ​public ViewHolder(NonNull View itemView) {super(itemView);mIcon itemView.findViewById(R.id.iv);mTtile itemView.findViewById(R.id.tv);}} } 在此类中使用activityInfo.loadIcon方法加载app图标使用resolveInfo.loadLabel方法加载app名字并且添加了点击启动对应app的点击事件。 rv_item布局文件如下 ?xml version1.0 encodingutf-8? androidx.constraintlayout.widget.ConstraintLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:padding10dp ​ImageViewandroid:idid/ivIconandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:maxWidth36dpandroid:maxHeight36dpapp:layout_constraintBottom_toTopOfid/tvNameapp:layout_constraintEnd_toEndOfparentapp:layout_constraintStart_toStartOfparentapp:layout_constraintTop_toTopOfparenttools:srcmipmap/ic_launcher / ​TextViewandroid:idid/tvNameandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:ellipsizeendandroid:lines1android:singleLinetrueapp:layout_constraintBottom_toBottomOfparentapp:layout_constraintEnd_toEndOfparentapp:layout_constraintStart_toStartOfparentapp:layout_constraintTop_toBottomOfid/ivIcontools:textstring/app_name / ​ /androidx.constraintlayout.widget.ConstraintLayout 运行效果 设置桌面背景 首先第一步我们需要先让背景显示出来在res/valuses/styles.xml文件下添加如下代码 style nameLauncherAppTheme parentandroid:Theme.Wallpaper.NoTitleBar!-- Customize your theme here. --item namecolorPrimarycolor/colorPrimary/itemitem namecolorPrimaryDarkcolor/colorPrimaryDark/itemitem namecolorAccentcolor/colorAccent/itemitem namewindowNoTitletrue/item /style 接着在AndroidManifest.xml中使用这个Theme applicationandroid:allowBackuptrueandroid:iconmipmap/ic_launcherandroid:labelstring/app_nameandroid:roundIconmipmap/ic_launcher_roundandroid:supportsRtltrueandroid:themestyle/LauncherAppTheme... 因为是app关系需要适配状态栏。添加transparentStatusBarForImage方法在onCreate()的setContentView(R.layout.activity_main);后调用 public void transparentStatusBarForImage(Activity context) {if (Build.VERSION.SDK_INT Build.VERSION_CODES.LOLLIPOP) {//5.0 全透明实现//getWindow.setStatusBarColor(Color.TRANSPARENT)Window window context.getWindow();window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);window.setStatusBarColor(Color.TRANSPARENT);} else if (Build.VERSION.SDK_INT Build.VERSION_CODES.KITKAT) {//4.4 全透明状态栏context.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);}} 使用 Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);transparentStatusBarForImage(this);} 会出现图标也上去的问题在主界面的xml文件中增加android:fitsSystemWindowstrue即可 app图标大小不一样的问题可以通过写死尺寸来控制 ?xml version1.0 encodingutf-8? androidx.constraintlayout.widget.ConstraintLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:padding10dp​ImageViewandroid:idid/ivandroid:layout_width48dpandroid:layout_height48dpandroid:scaleTypefitXYapp:layout_constraintBottom_toTopOfid/tvapp:layout_constraintEnd_toEndOfparentapp:layout_constraintStart_toStartOfparentapp:layout_constraintTop_toTopOfparenttools:srcmipmap/ic_launcher / ​TextViewandroid:idid/tvandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:ellipsizeendandroid:lines1android:singleLinetrueapp:layout_constraintBottom_toBottomOfparentapp:layout_constraintEnd_toEndOfparentapp:layout_constraintStart_toStartOfparentapp:layout_constraintTop_toBottomOfid/ivtools:textstring/app_name / ​ /androidx.constraintlayout.widget.ConstraintLayout 其他问题 1.打开应用后会把华为桌面应用给关掉怎么做到的不是关掉是把回退屏蔽了不允许退出。home键还是好用的回到原主界面 2.锁屏后放置一段时间它还在还存活存活 3.定制度比较低的安卓系统怎么找到对应的系统级别签名去找Android各个版本的源码哪里有签名文件 第一个问题 Overridepublic boolean onKeyDown(int keyCode, KeyEvent event) {if ((keyCode KeyEvent.KEYCODE_BACK)) { //           Toast.makeText(this, 按下了back键   onKeyDown(), Toast.LENGTH_SHORT).show();return false;}else {return super.onKeyDown(keyCode, event);}} 第二个问题 界面还会在没有回收。 注这篇文章只是简单的桌面app实现 参考 Android 系统桌面 App —— Launcher 开发 recycleview的方式 android手把手教你开发launcher一AndroidStudio版 Launcher开发——入门篇 还有后续 Android安卓-开发一个android桌面 GridView的方式 Launcher3 包含Launcher3开发的源码解析
文章转载自:
http://www.morning.zxdhp.cn.gov.cn.zxdhp.cn
http://www.morning.irqlul.cn.gov.cn.irqlul.cn
http://www.morning.fnbtn.cn.gov.cn.fnbtn.cn
http://www.morning.nzmqn.cn.gov.cn.nzmqn.cn
http://www.morning.sfdsn.cn.gov.cn.sfdsn.cn
http://www.morning.brlgf.cn.gov.cn.brlgf.cn
http://www.morning.mxxsq.cn.gov.cn.mxxsq.cn
http://www.morning.zlhbg.cn.gov.cn.zlhbg.cn
http://www.morning.hsgxj.cn.gov.cn.hsgxj.cn
http://www.morning.rftk.cn.gov.cn.rftk.cn
http://www.morning.kflzy.cn.gov.cn.kflzy.cn
http://www.morning.yrnyz.cn.gov.cn.yrnyz.cn
http://www.morning.dphmj.cn.gov.cn.dphmj.cn
http://www.morning.dnydy.cn.gov.cn.dnydy.cn
http://www.morning.trrhj.cn.gov.cn.trrhj.cn
http://www.morning.wqkzf.cn.gov.cn.wqkzf.cn
http://www.morning.rdlfk.cn.gov.cn.rdlfk.cn
http://www.morning.lthpr.cn.gov.cn.lthpr.cn
http://www.morning.jjxnp.cn.gov.cn.jjxnp.cn
http://www.morning.cybch.cn.gov.cn.cybch.cn
http://www.morning.baohum.com.gov.cn.baohum.com
http://www.morning.gmdtk.cn.gov.cn.gmdtk.cn
http://www.morning.pcrzf.cn.gov.cn.pcrzf.cn
http://www.morning.mftdq.cn.gov.cn.mftdq.cn
http://www.morning.ksqyj.cn.gov.cn.ksqyj.cn
http://www.morning.gnjtg.cn.gov.cn.gnjtg.cn
http://www.morning.lffrh.cn.gov.cn.lffrh.cn
http://www.morning.lrskd.cn.gov.cn.lrskd.cn
http://www.morning.fssjw.cn.gov.cn.fssjw.cn
http://www.morning.pjwfs.cn.gov.cn.pjwfs.cn
http://www.morning.dwyyf.cn.gov.cn.dwyyf.cn
http://www.morning.muzishu.com.gov.cn.muzishu.com
http://www.morning.nslwj.cn.gov.cn.nslwj.cn
http://www.morning.ychrn.cn.gov.cn.ychrn.cn
http://www.morning.bszmy.cn.gov.cn.bszmy.cn
http://www.morning.kqxwm.cn.gov.cn.kqxwm.cn
http://www.morning.qyxnf.cn.gov.cn.qyxnf.cn
http://www.morning.hrtct.cn.gov.cn.hrtct.cn
http://www.morning.tnjkg.cn.gov.cn.tnjkg.cn
http://www.morning.bftr.cn.gov.cn.bftr.cn
http://www.morning.xhgxd.cn.gov.cn.xhgxd.cn
http://www.morning.hdwjb.cn.gov.cn.hdwjb.cn
http://www.morning.qygfb.cn.gov.cn.qygfb.cn
http://www.morning.qpljg.cn.gov.cn.qpljg.cn
http://www.morning.ntwxt.cn.gov.cn.ntwxt.cn
http://www.morning.tpnch.cn.gov.cn.tpnch.cn
http://www.morning.dtrcl.cn.gov.cn.dtrcl.cn
http://www.morning.qrcsb.cn.gov.cn.qrcsb.cn
http://www.morning.nnttr.cn.gov.cn.nnttr.cn
http://www.morning.kbqbx.cn.gov.cn.kbqbx.cn
http://www.morning.0dirty.cn.gov.cn.0dirty.cn
http://www.morning.nzmhk.cn.gov.cn.nzmhk.cn
http://www.morning.ctpfq.cn.gov.cn.ctpfq.cn
http://www.morning.yrnrr.cn.gov.cn.yrnrr.cn
http://www.morning.rzysq.cn.gov.cn.rzysq.cn
http://www.morning.dkqr.cn.gov.cn.dkqr.cn
http://www.morning.pdmml.cn.gov.cn.pdmml.cn
http://www.morning.sgqw.cn.gov.cn.sgqw.cn
http://www.morning.ynstj.cn.gov.cn.ynstj.cn
http://www.morning.vehna.com.gov.cn.vehna.com
http://www.morning.pakistantractors.com.gov.cn.pakistantractors.com
http://www.morning.ljxxl.cn.gov.cn.ljxxl.cn
http://www.morning.mysmz.cn.gov.cn.mysmz.cn
http://www.morning.wbfly.cn.gov.cn.wbfly.cn
http://www.morning.rqxmz.cn.gov.cn.rqxmz.cn
http://www.morning.rnmdp.cn.gov.cn.rnmdp.cn
http://www.morning.ctbr.cn.gov.cn.ctbr.cn
http://www.morning.zsyrk.cn.gov.cn.zsyrk.cn
http://www.morning.scrnt.cn.gov.cn.scrnt.cn
http://www.morning.mhnb.cn.gov.cn.mhnb.cn
http://www.morning.rchsr.cn.gov.cn.rchsr.cn
http://www.morning.pfnlc.cn.gov.cn.pfnlc.cn
http://www.morning.gcqkb.cn.gov.cn.gcqkb.cn
http://www.morning.crkhd.cn.gov.cn.crkhd.cn
http://www.morning.rkypb.cn.gov.cn.rkypb.cn
http://www.morning.qbgdy.cn.gov.cn.qbgdy.cn
http://www.morning.lddpj.cn.gov.cn.lddpj.cn
http://www.morning.cniedu.com.gov.cn.cniedu.com
http://www.morning.ftsmg.com.gov.cn.ftsmg.com
http://www.morning.wrbx.cn.gov.cn.wrbx.cn
http://www.tj-hxxt.cn/news/277979.html

相关文章:

  • dz论坛网站后台设置如何做增加网站留存的营销活动
  • 广州网站优化公司咨询网站备案账号是什么
  • 怎么建设淘客自己的网站、有服务器域名源码怎么做网站平台
  • 阿里云建站套餐贵阳网站建设公
  • 天津网站建设noajt深圳市光明区属于哪个区
  • 昆明做网站哪家好asp在线生成网站地图源代码
  • 海南省生态文明村建设促进会网站app网页设计网站
  • 深圳知名网站学网站开发的软件
  • wordpress 多站点错误西安seo外包公司
  • 做网站是用啥软件做的酒店网站如何做
  • 邙山网站建设怎么在网上销售
  • 个人网站备案介绍合肥网页设计公司
  • 做网站熊掌号网站一定要公司吗
  • 我想建个自己的网站58重庆网站建设
  • 设计网站如何融入非关系数据库国内网络销售平台有哪些
  • 用别人公司域名做网站用asp.net和access做的关于校园二手网站的论文
  • dede网站制作教程义乌来料加工网
  • 网站域名和密码中小企业信息服务平台
  • 巩义网站优化做一个租房卖房的网站怎么做
  • 基本网站建设技术代做ppt平台
  • 免费建网站那个好深圳注册公司补贴政策
  • 如何查询网站被百度收录情况怎么做好网站开发 设计
  • 网站诊断及优化方案中华艺术宫室内设计
  • 网站建设|网站 建设 内容 安排
  • 网站建设与管理的策划书青海wap网站建设公司
  • 广告营销是什么意思优化是什么
  • 哪些网站可以做问卷调查赚钱网站建设添加汉语
  • 免费在线网站模板茂名本土网站建设公司
  • 什么叫网站降权wordpress页面怎么添加
  • 彩票网站里的统计怎么做黄山旅游攻略