前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Learn Android Studio 3Android architectureAndroid ComponentsDesign editor.pngKeyboard Shortcuts for

Learn Android Studio 3Android architectureAndroid ComponentsDesign editor.pngKeyboard Shortcuts for

作者头像
iOSDevLog
发布2018-05-17 11:01:04
6880
发布2018-05-17 11:01:04
举报
文章被收录于专栏:iOSDevLog

Android architecture


Android architecture.png

Android Components


Component

What It Does

Example

Activity base class: android.app.Activity

Holds, displays the user interface elements (View and ViewGroups). It’s a focused thing a user can do with your application

View a single e-mail message, take notes

Service base class: android.app.Service

Run a process in the background

Download a large file from the Internet, play background music

BroadcastReceiver base class: android.content.BroadcastReceiver

Receive messages either from the Android system or from applications

Display a warning message when the device battery dips to below 10%

ContentProvider base class: android.content.ContentProvider

Store and retrieve data, like a database

Contacts or address book on your phone. Any application can look up and add data to the phonebook

Design editor.png


Design editor.png

Keyboard Shortcuts for Code Folding


Task

Windows or Linux

macOS

Open Settings or Preferences dialog

Ctrl + Alt + S

⌘ + ','

Expand code block

Ctrl + Shift + '+' (plus)

(comma) ⌘ + '+' (plus)

Collapse code block

Ctrl + Shift + '-' (minus)

⌘ + '-' (minus)

Constraint handles and sizing handles


Constraint handles and sizing handles.png

Attributes inspector


Attributes inspector.png

Constraint inspectors


Constraint inspectors.png

Activity Life cycle


Activity Life cycle.png

Callback Methods


Event

Description

onCreate

Called when the activity is first created; you can put your initialization codes here

onRestart

When the activity has been stopped and restarted again. This is always followed by onStart

onStart

When the activity is starting to become visible to the user

onResume

The activity is ready to interact with the user, at this point; the activity is at the top of the activity stack, and it occupies the whole screen

onPause

When the activity is about to go to the background; this can happen when another activity grabs the focus

onStop

When the activity is no longer visible to the user

onDestroy

Called when the activity is destroyed. For the application to come back, it needs to be created again

https://material.io


https://www.materialpalette.com/l

www.materialpalette.com.png

AsyncTask and MainActivity


AsyncTask and MainActivity.png

Arguments to the AsyncTask Class


Parameter

Description

1st arg (Params)

What information do you want to pass to the background thread? This is usually the UI element(s) that you want to update. When you call execute from MainActivity, you will need to pass this parameter to the AsyncTask. This param automatically makes its way to the doInBackground method. In our example, this is a text view object. We want the background thread to have access to this UI element as it does its work

2nd arg (Progress)

What type of information do you want the background thread to pass back to onProgressUpdate method so you can specify the status of a long running operation to the user? In our case, we want to update the text attribute of the text view, so this is a String object

3rd param (Result)

What kind of data do you want to use to specify the status of doInBackground when it finishes the task? In our case, I just wanted it to return true if everything went well, so the third parameter is a Boolean

Storage options


Storage

Description

SharedPreferences

This is the simplest form of storage. It’s just a dictionary object that uses the key/value pair idiom. This is useful if your data is simple enough to be structured as a dictionary object (key/value pairs). Android stores these files internally as XML files. SharedPrefs only stores simple data types (e.g., String and primitive data types). It cannot store more complex data

Internal or external storage

Stores data in the device storage (internal) or media storage like SDCARD (external). If you need to store data that is more complex in structure than a dictionary can afford (e.g., audio, video files), you may want to consider using this type of persistence mechanism

SQLite database

This one uses a relational database. If you have worked with other databases before—MS SQL server, MySQL, PostgreSQL, or any other relational database—this is essentially the same. Data is stored in tables, and you need to use SQL statements to create, read, update, and delete data

Network

If you can assume that your users will always have Internet access and you have a database server that is hosted on the Internet, then you can use this option. This setup can get a bit complicated because you will need to host the database somewhere (Amazon, Google, any other cloud provider), provide a REST interface for the data, and use an HTTP library as a client in the Android app. We won’t cover this topic in this book

Content Providers

Content Provider is another component on the Android platform; it’s right up there with Activities, Services, and Broadcast receivers. This component makes data available to applications other than itself. Think of it like a database that has public HTTP API layer. Any application that communicates over HTTP can read and write data to it

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018.03.13 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Android architecture
  • Android Components
  • Design editor.png
  • Keyboard Shortcuts for Code Folding
  • Constraint handles and sizing handles
  • Attributes inspector
  • Constraint inspectors
  • Activity Life cycle
    • Callback Methods
    • https://material.io
    • AsyncTask and MainActivity
    • Arguments to the AsyncTask Class
    • Storage options
    相关产品与服务
    云数据库 MySQL
    腾讯云数据库 MySQL(TencentDB for MySQL)为用户提供安全可靠,性能卓越、易于维护的企业级云数据库服务。其具备6大企业级特性,包括企业级定制内核、企业级高可用、企业级高可靠、企业级安全、企业级扩展以及企业级智能运维。通过使用腾讯云数据库 MySQL,可实现分钟级别的数据库部署、弹性扩展以及全自动化的运维管理,不仅经济实惠,而且稳定可靠,易于运维。
    领券
    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档