node to enable or disable multi-window display: android:resizeableActivity=["true" | "false"] If your app targets Android N, but you do not specify a value for this attribute, the attribute's value defaults to true.
indicate whether the activity supports picture-in-picture display. This attribute is ignored if android:resizeableActivity is false. android:supportPictureInPicture=["true" | "false"] ※ Android TV
freeform mode. android:defaultHeight Default height of the activity when launched in freeform mode. android:gravity Initial placement of the activity when launched in freeform mode. See the Gravity reference for suitable values. android:minHeight, android:minWidth Minimum height and minimum width for the activity in both split-screen and freeform modes.
onCreate() onResume() onPostCreate() onPostResume() Activity Running onPause() onStop() onDestroy() onStart() onUserLeaveHint() onSaveInstanceState() Activity Shutdown Activity Shutdown User navigates to the activity User navigates to the activity Apps with higher priority need memory MultiWindow (unfrocks) & MultiWindow (focus)
the action's intent. private static final String KEY_TEXT_REPLY = "key_text_reply"; String replyLabel = getResources().getString(R.string.reply_label); RemoteInput remoteInput = new RemoteInput.Builder(KEY_TEXT_REPLY).setLabel(replyLabel).build(); Create instance of RemoteInputBuilder // Create the reply action and add the remote input. Notification.Action action = new Notification.Action.Builder(R.drawable.ic_reply_icon, getString(R.string.label), replyPendingIntent) .addRemoteInput(remoteInput) .build(); Attach the RemoteInput object to an action using addRemoteInput(). // Build the notification and add the action. Notification newMessageNotification = new Notification.Builder(mContext) .setSmallIcon(R.drawable.ic_message) .setContentTitle(getString(R.string.title)) .setContentText(getString(R.string.content)) .addAction(action)) .build(); // Issue the notification. NotificationManager notificationManager =NotificationManager.from(mContext); notificationManager.notify(notificationId, newMessageNotification); Apply the action to a notification and issue the notification.
wake locks. • Standard AlarmManager alarms are deferred to the next maintenance window. The system does not perform Wi-Fi scans. • The system does not allow sync adapters to run. • The system does not allow JobScheduler to run
only 4 circles (as you can see in the picture), because they are only schematic but you should take into consideration the Dependency Rule: source code dependencies can only point inwards and nothing in an inner circle can know anything at all about something in an outer circle.
by keeping the business rules not knowing anything at all about the outside world, thus, they can can be tested without any dependency to any external element.
and animations happens. It uses no more than a Model View Presenter (MVP from now on), but you can use any other pattern like MVC or MVVM. I will not get into details on it, but here fragments and activities are only views, there is no logic inside them other than UI logic, and this is where all the rendering stuff takes place.
this layer. Regarding the android project, you will see all the interactors (use cases) implementations here as well. This layer is a pure java module without any android dependencies. All the external components use interfaces when connecting to the business objects.
this layer through a UserRepository implementation (the interface is in the domain layer) that uses a Repository Pattern with a strategy that, through a factory, picks different data sources depending on certain conditions. For instance, when getting a user by id, the disk cache data source will be selected if the user already exists in cache, otherwise the cloud will be queried to retrieve the data and later save it to the disk cache. The idea behind all this is that the data origin is transparent for the client, which does
final String lastName; public final int age; public User(String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName; } } Implementation Code public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_m User user = new User("Hao", "Hao"); binding.setUser(user); } }
http://square.github.io/retrofit/ Retrofit has been able to fulfill every networking demand that I’ve thrown at it. It’s a breeze to add headers, use your own JSON marshaller (GSON is built in), or even pass in your own network client. RxJava support was recently added as well (can return Observables instead of scalar values). Check out how little you need to get started: //Create a Model that represents your JSON data (It’s ok if fields are missing that are present in JSON) public class User { public String avatar_url; public String login; } //Create an interface public interface Github { @GET(“/search/users”) UserResponse users(@Query(“q”) String name); } //Auto Generate implementation from Interface Github api = new RestAdapter.Builder() .setEndpoint(“https://api.github.com") .build() .create(Github.class) // user your endpoint UserResponse response =api.users(request.getName()); https://goo.gl/TXhwKH
network-oriented tasks, and let Google Play services batch network operations across the system. This greatly simplifies the implementation of common patterns, such as waiting for network connectivity, network retries, and back-off. https://goo.gl/Hpf1gV // Schedule a task to occur between five and fifteen minutes from now: OneoffTask myTask = new OneoffTask.Builder() .setService(MyGcmTaskService.class) .setExecutionWindow( 5 * DateUtil.MINUTE_IN_SECONDS, 15 * DateUtil.MINUTE_IN_SECONDS) .setTag("test-upload") .build(); GcmNetworkManager.getInstance(this).schedule(myTask);
feel that the system is reacting instantaneously, meaning that no special feedback is necessary except to display the result. 2. 1.0 sec is about the limit for the user's flow of thought to stay uninterrupted, even though the user will notice the delay. 3. 10 sec is about the limit for keeping the user's attention focused on the dialogue. 4. 60 FPS is most people won’t perceive much smoother images above 60 fps. Response Times: The 3 Important Limits The Illusion of Motion
Lint Runtime Exception Strict Mode Thread Policy : That would help to detect if our code have some slow operation VM Policy : detect vulnerability problem, code have memory leak operation
Android Developers https://goo.gl/V95BJg • Best Practices for Performance https://goo.gl/8qeKb7 • Optimize Your App https://goo.gl/e2oKYK • Principles of Mobile App Design: Engage Users and Drive Conversions https://goo.gl/LUCZZG
background activities http://goo.gl/zWNEaL • Best Practices for Background Jobs https://goo.gl/u6NYhX • Performance RAIL's https://goo.gl/QePFd8 • Response Time: The 3 Important Limits https://goo.gl/hpm3yj • The Illusion of Motion https://goo.gl/tMspjz