源码
public class HintActivity extends AppCompatActivity {
public static final String TAG = "HintActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hint);
}
@Override
protected void onStop() {
super.onStop();
Toast.makeText(this,"HintActivity onStop",Toast.LENGTH_SHORT).show();
}
}
// 布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
android:background="#E40F0F">
<Button
android:id="@+id/confirm"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_alignParentBottom ="true"
android:background="#E4DADA"
android:textSize="35dp"
android:text="text" />
</RelativeLayout>
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private Button hint;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main7);
hint = findViewById(R.id.hintClick);
hint.setOnClickListener(this::onClick);
}
@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.hintClick:
Toast.makeText(this,"to into HintActivity ",Toast.LENGTH_SHORT).show();
Intent intent = new Intent("android.intent.action.SHOWHINTACTIVITY");
startActivity(intent);
break;
}
}
}
// AndroidManifest.xml 配置方式
<activity
android:name=".demo1.HintActivity"
android:excludeFromRecents="true"
android:exported="true"
android:theme="@style/Theme.AppCompat.Dialog">
<intent-filter>
<action android:name="android.intent.action.SHOWHINTACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".demo1.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
标签:Toast,HintActivity,hint,安卓,savedInstanceState,---,Override,Android,onCreate
From: https://www.cnblogs.com/kato-T/p/16615399.html