본문 바로가기
  • Tried. Failed. Logged.
728x90

안드로이드 스튜디오16

안드로이드 스튜디오 - 백그라운드 실행(서비스) 관련 예제 코드 Create a service public class YourService extends Service { @Nullable @Override public IBinder onBind(Intent intent) { return null; } @Override public int onStartCommand(Intent intent, int flags, int startId) { // do your jobs here return super.onStartCommand(intent, flags, startId); }}   Create an Application class and start your service public class Ap.. 2024. 10. 13.
안드로이드 스튜디오 - 화면 켜짐 상태 유지 public class MyActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); }} 2024. 10. 10.
안드로이드 스튜디오 - 웹뷰(WebView) 자바스크립트 조작 private Boolean isLoadingFinished = false; ... WebView webView = findViewById(R.id.webView); webView.setWebViewClient(new WebViewClient(){ @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); Toast.makeText(getApplicationContext(), "페이지 로드 중...", Toast.LENGTH_LONG).show(); isLoadingFinished = false; } @Override public void onPag.. 2023. 8. 23.
안드로이드 스튜디오 - 스와이프 리스트 메뉴 구현 SwipeMenuListView: https://github.com/baoyongzhang/SwipeMenuListView GitHub - baoyongzhang/SwipeMenuListView: [DEPRECATED] A swipe menu for ListView. [DEPRECATED] A swipe menu for ListView. Contribute to baoyongzhang/SwipeMenuListView development by creating an account on GitHub. github.com ListView 조작 블로그: https://lktprogrammer.tistory.com/163 [Android] 안드로이드 - 리스트뷰(ListView) 구현 리스트뷰(ListView)는.. 2022. 4. 7.
안드로이드 스튜디오 - HTTP 통신 라이브러리(Volley) [build.gradle] implementation 'com.android.volley:volley:버전' [AndroidManifest.xml] usesCleartextTraffic로 https 사용 지원 활성화 [mainActivity.java] String url ="https://www.google.com"; RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext()); StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener() { @Override public void onResponse(String res.. 2022. 4. 5.
안드로이드 스튜디오 - RecyclerView(리사이클러뷰) 조작 총 5가지의 작업이 필요, 각각 activity_main.xml, 아이템.xml, 데이터.java, 리사이클러_어댑터.java, MainActivity.java [activity_main.xml] 도화지 역할을 해줄 activity_main.xml에 RecyclerView를 넣음 [item.xml] 리스트에 들어갈 아이템들을 꾸며줌 [Data.java] package com.app.listapp; public class Data { private String name; private String phone; public Data(String name, String phone){ this.name = name; this.phone = phone; } public String getName(){ return.. 2022. 3. 30.
안드로이드 스튜디오 - notification Intent 진행하고 있던 MainActivity로 다시 이동하기 해결 Intent notificationIntent = new Intent(getApplicationContext(), MainActivity.class); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 진행하고 있는 MainActivity로 다시 이동을 하고 싶은 경우. 출처: https://like-tomato.tistory.com/156 [Notification] 안드로이드 앱 중복 실행 문제 완벽 해결 방법 안드로이드 애플리케이션을 개발하다 보면 대부분.. 2022. 3. 22.
안드로이드 스튜디오 - 앱 아이콘 숨기기/보이기 [숨기기] PackageManager p = getPackageManager(); ComponentName componentName = new ComponentName(this, com.apps.MainActivity.class); // activity which is first time open in manifiest file which is declare as p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); [보이기] PackageManager p = getPackageManager(); ComponentName componentN.. 2021. 12. 19.
안드로이드 스튜디오 - 부팅시 자동 실행 [AndroidManifest.xml] [StartActivityOnBootReceiver.java] package com.codinginflow.onbootreceiverexample; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; public class StartActivityOnBootReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAct.. 2021. 12. 19.
안드로이드 스튜디오 - 백그라운드 서비스 실행 출처: https://stackoverflow.com/questions/46716069/how-to-make-background-process-in-android-studio How To Make Background Process in Android Studio hi guys thank you for answering my question,i have made an android app in android studio i want to make funtion when i close the app the function start automatically in background is there any way ... stackoverflow.com [액티비티] public class App extends .. 2021. 12. 19.
안드로이드 스튜디오 - The minCompileSdk (31) specified in adependency's... 오류 해결 build.gradle로 들어가서 compileSdkVersion을 31로 수정 출처: https://ardmos.tistory.com/entry/The-minCompileSdk-31-specified-in-adependencys-AAR-metadata [오류 해결] The minCompileSdk (31) specified in adependency's AAR metadata ... 어제 새로 만든 프로젝트를 빌드하려던 도중 The minCompileSdk (31) specified in a dependency's AAR metadata ... 라는 내용의 오류가 발생했다. - 해결 방법! bulid.gradle (Module) 파일의 compileSdk와 targ.. ardmos.tistory.com 2021. 11. 24.
안드로이드 스튜디오 - fragment 조작하기 액티비티의 기본 레이아웃을 LinearLayout으로 변경 기본 horizontal를 vertical으로 변경 LinearLayout 자식을 두 개 넣어주기 각각 fragment 뷰어, fragment 전환 역할을 할 거임 첫 번째 자식 LinearLayout의 id를 Container로 수정 두 번째의 자식 LinearLayout에 button들을 넣어줌 그런데 미리보기에 button들이 보이지 않는 것을 볼 수 있는데, 이는 Container가 부모의 크기만큼 설정이 되어있어서 버튼의 레이아웃이 밀려난 것임 Container의 layout_weight 속성 값으로 1을 준다. 버튼 레이아웃의 layout_height를 wrap_content로 변경해준다. 그럼 버튼들이 제대로 나오는 것을 볼 수 있다.. 2021. 11. 23.
728x90