Solve initial commit
	
		
			
	
		
	
	
		
	
		
			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:
		| @@ -32,6 +32,10 @@ android { | |||||||
| } | } | ||||||
|  |  | ||||||
| dependencies { | dependencies { | ||||||
|  |     implementation("androidx.appcompat:appcompat:1.7.0") | ||||||
|  |     implementation("com.google.android.material:material:1.12.0") | ||||||
|  |     implementation("androidx.activity:activity:1.9.3") | ||||||
|  |     implementation("androidx.constraintlayout:constraintlayout:2.2.0") | ||||||
|     defaultLibrary() |     defaultLibrary() | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -11,6 +11,16 @@ | |||||||
|         android:roundIcon="@mipmap/ic_launcher_round" |         android:roundIcon="@mipmap/ic_launcher_round" | ||||||
|         android:supportsRtl="true" |         android:supportsRtl="true" | ||||||
|         android:theme="@style/Theme.Default" |         android:theme="@style/Theme.Default" | ||||||
|         tools:targetApi="31" /> |         tools:targetApi="33" > | ||||||
|  |         <activity | ||||||
|  |             android:name=".MainActivity" | ||||||
|  |             android:exported="true" > | ||||||
|  |             <intent-filter> | ||||||
|  |                 <action android:name="android.intent.action.MAIN" /> | ||||||
|  |  | ||||||
|  |                 <category android:name="android.intent.category.LAUNCHER" /> | ||||||
|  |             </intent-filter> | ||||||
|  |         </activity> | ||||||
|  |     </application> | ||||||
|  |  | ||||||
| </manifest> | </manifest> | ||||||
							
								
								
									
										55
									
								
								app/src/main/java/ru/myitschool/work/MainActivity.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								app/src/main/java/ru/myitschool/work/MainActivity.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,55 @@ | |||||||
|  | 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); | ||||||
|  |             } | ||||||
|  |         }; | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										16
									
								
								app/src/main/res/layout/activity_main.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								app/src/main/res/layout/activity_main.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | |||||||
|  | <?xml version="1.0" encoding="utf-8"?> | ||||||
|  | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||||
|  |     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||||
|  |     xmlns:tools="http://schemas.android.com/tools" | ||||||
|  |     android:layout_width="match_parent" | ||||||
|  |     android:layout_height="match_parent" | ||||||
|  |     android:orientation="vertical" | ||||||
|  |     tools:context=".MainActivity"> | ||||||
|  |  | ||||||
|  |     <include | ||||||
|  |         android:id="@+id/content" | ||||||
|  |         layout="@layout/content_main" /> | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | </androidx.constraintlayout.widget.ConstraintLayout> | ||||||
							
								
								
									
										21
									
								
								app/src/main/res/layout/content_main.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								app/src/main/res/layout/content_main.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | |||||||
|  | <?xml version="1.0" encoding="utf-8"?> | ||||||
|  | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||||
|  |     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||||
|  |     xmlns:tools="http://schemas.android.com/tools" | ||||||
|  |     android:layout_width="match_parent" | ||||||
|  |     android:layout_height="match_parent" | ||||||
|  |     android:orientation="vertical" | ||||||
|  |     tools:context=".MainActivity"> | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     <TextView | ||||||
|  |         android:id="@+id/status_text" | ||||||
|  |         android:layout_width="match_parent" | ||||||
|  |         android:layout_height="0dp" | ||||||
|  |         android:layout_gravity="center_vertical" | ||||||
|  |         android:layout_weight="1" | ||||||
|  |         android:gravity="center" | ||||||
|  |         android:text="@string/text" | ||||||
|  |         android:textSize="25sp" /> | ||||||
|  |  | ||||||
|  | </LinearLayout> | ||||||
| @@ -1,3 +1,4 @@ | |||||||
| <resources> | <resources> | ||||||
|     <string name="app_name">Work</string> |     <string name="app_name">Broadcast receiver</string> | ||||||
|  |     <string name="text">Ожидание…</string> | ||||||
| </resources> | </resources> | ||||||
		Reference in New Issue
	
	Block a user