본문 바로가기

안드로이드+자바40

안드로이드 6.0이상 권한문제시 추가해야할 코드 //안드로이드 버전 6.0 이상부터 어떤 권한들은 앱 안에서 사용 승인을 받아야 한다. //이 때 필요한 코드이다. private void checkPermission(){ // Here, thisActivity is the current activity //밑에는 체크할 권한 넣고 체크하면 됨. if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != Pa.. 2017. 5. 15.
SharedPreference를 사용하여 다른 activity에 값 전달하기 아래 SharedPreference코드는 정보를 db에 저장하여 다른 화면에서도 해당하는 키 값으로 불러올 수 있게 하기위해서 사용될 수 있다. SharedPreferences sharedPreferences = getSharedPreferences("email", MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString("email", "넣을 이메일 주소"); editor.apply(); //현재 시간 받아오는 코드 String currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date()); Intent에 putExtra로 .. 2017. 5. 1.
안드로이드 툴바 오류 뜰 때(This Activity already has an action bar supplied by the window decor) java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.대충 해석해 보면 이 액티비티는 이미 window decor가 제공한 액션바를 가지고 있다.그러니 툴바를 사용하려면 액션바를 없애라.. 이정도 인것 같다. manifest에서 DrawerLayout을 사용하는 activity안에 아래의 코드를 넣으면 에러가 해결된다.android:theme="@style/App.. 2017. 4. 24.
안드로이드 구글 로그인하기 전체 코드 import android.content.Intent; import android.support.annotation.NonNull; import android.support.v4.app.FragmentActivity; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.TextView; import android.widget.Toast; import com.google.android.gms.auth.api.Auth; import com.google.android.gms.auth.api.signi.. 2017. 3. 4.