Several knowledge points derived from the home page interface (2)

1.scrollview nested recyclerview
Don't forget to add
recyclerView.setNestedScrollingEnabled(false); 
Otherwise, scrolling will freeze
2.onNewIntent:
First of all, by default, when you start an Activity through an Intent, even if there is already an identical running Activity, the system will create a new Activity instance and display it. In order to prevent the Activity from being instantiated multiple times, we need to implement the single-task mode by configuring the activity's loading mode (launchMode) in AndroidManifest.xml, as follows:


<activity android:label="@string/app_name" android:launchmode="singleTask"android:name="Activity1"></activity>

When launchMode is singleTask, an Activity is started through Intent. If an instance already exists in the system, the system will send the request to this instance, but at this time, the system will not call onCreate, which normally processes the request data. method, instead call the onNewIntent method as follows:

protected void onNewIntent(Intent intent) {

super .onNewIntent(intent);

setIntent(intent); // must store the new intent unless getIntent() will return the old one

processExtraData();

}
   Everyone encounters a situation where the Activity of an application is called and started in multiple ways, and multiple calls hope that only one instance of the Activity exists, which requires the onNewIntent (Intent intent) method of the Activity. Just add your own implementation of onNewIntent(intent) to the Activity and set lanuchMode="singleTask" to the Activity in the Manifest.
       onNewIntent() is very easy to use. When the Activity is first started, it executes subsequent life cycle functions such as onCreate()---->onStart()---->onResume(), which means that starting the Activity for the first time does not It will be executed to onNewIntent(). And if you want to start Activity later, it is to execute onNewIntent()---->onResart()------>onStart()----->onResume( ). If the android system releases the existing Activity due to insufficient memory, the Activity will be restarted when it is called again, that is, onCreate()---->onStart()---->onResume() and so on.

     When calling onNewIntent(intent), you need to use setIntent(intent) in onNewIntent() to assign it to the Activity's Intent. Otherwise, subsequent getIntent() will get the old Intent.
Three: I encountered an error when using the emulator
Error when apk runs: UnsatisfiedLinkError: dalvik.system.PathClassLoader exception reason and solution
Four: other
The difference between the android attributes layout_toRightOf and layout_toEndOf
    The result is the same. The old version of the API supports layout_toRightOf, and the new version of the API is recommended to use layout_toEndOf. In order to take into account the old and new versions, it is best to use both at the same time.
Detailed explanation of xml tools attribute in android
  1. xmlns:tools="http://schemas.android.com/tools"
  1. <TextView
  2.  android:id="@+id/text_main"
  3.  android:layout_width="match_parent"
  4.  android:layout_height="wrap_content"
  5.  android:textAppearance="@style/TextAppearance.Title"
  6.  android:layout_margin="@dimen/main_margin"
  7.  tools:text="I am a title" />

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325808559&siteId=291194637