Template initial state
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				Merge core/template-android-project to this repo / merge-if-needed (push) Has been cancelled
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	Merge core/template-android-project to this repo / merge-if-needed (push) Has been cancelled
				
			This commit is contained in:
		| @@ -1,55 +1,16 @@ | ||||
| package ru.myitschool.work; | ||||
|  | ||||
| import static java.util.Map.entry; | ||||
|  | ||||
| import android.content.BroadcastReceiver; | ||||
| import android.content.Context; | ||||
| import android.content.Intent; | ||||
| import android.os.Build; | ||||
| import android.os.Bundle; | ||||
|  | ||||
| import androidx.annotation.Nullable; | ||||
| import androidx.annotation.RequiresApi; | ||||
| import androidx.appcompat.app.AppCompatActivity; | ||||
|  | ||||
| import java.util.Map; | ||||
|  | ||||
| import ru.myitschool.work.databinding.ActivityMainBinding; | ||||
|  | ||||
| @RequiresApi(api = Build.VERSION_CODES.TIRAMISU) | ||||
| public class MainActivity extends AppCompatActivity { | ||||
|  | ||||
|     final static Map<String, String> CodelabActionsMap = Map.ofEntries( | ||||
|             entry(Intent.ACTION_AIRPLANE_MODE_CHANGED, "ACTION_AIRPLANE_MODE_CHANGED"), | ||||
|             entry(Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED, "ACTION_APPLICATION_RESTRICTIONS_CHANGED"), | ||||
|             entry(Intent.ACTION_APPLICATION_LOCALE_CHANGED, "ACTION_APPLICATION_LOCALE_CHANGED"), | ||||
|             entry(Intent.ACTION_ASSIST, "ACTION_ASSIST"), | ||||
|             entry(Intent.ACTION_BATTERY_CHANGED, "ACTION_BATTERY_CHANGED"), | ||||
|             entry(Intent.ACTION_BATTERY_LOW, "ACTION_BATTERY_LOW"), | ||||
|             entry(Intent.ACTION_BATTERY_OKAY, "ACTION_BATTERY_OKAY"), | ||||
|             entry(Intent.ACTION_CALL, "ACTION_CALL"), | ||||
|             entry(Intent.ACTION_DATE_CHANGED, "ACTION_DATE_CHANGED"), | ||||
|             entry(Intent.ACTION_DEFAULT, "ACTION_DEFAULT"), | ||||
|             entry(Intent.ACTION_HEADSET_PLUG, "ACTION_HEADSET_PLUG"), | ||||
|             entry(Intent.ACTION_LOCALE_CHANGED, "ACTION_LOCALE_CHANGED"), | ||||
|             entry(Intent.ACTION_TIME_TICK, "ACTION_TIME_TICK") | ||||
|     ); | ||||
|  | ||||
|     ActivityMainBinding ui; | ||||
|  | ||||
|     @Override | ||||
|     protected void onCreate(@Nullable Bundle savedInstanceState) { | ||||
|         super.onCreate(savedInstanceState); | ||||
|         ui = ActivityMainBinding.inflate(getLayoutInflater()); | ||||
|         setContentView(ui.getRoot()); | ||||
|     } | ||||
|  | ||||
|     public BroadcastReceiver makeBroadcastReceiver() { | ||||
|         return new BroadcastReceiver() { | ||||
|             public void onReceive(Context context, Intent intent) { | ||||
|                 var text = CodelabActionsMap.get(intent.getAction()); | ||||
|                 if (text != null) ui.content.statusText.setText(text); | ||||
|             } | ||||
|         }; | ||||
|         setContentView(R.layout.activity_main); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user