Skip to content

Instantly share code, notes, and snippets.

View kazuiains's full-sized avatar

Muhammad Adi Yusuf kazuiains

  • Pradita Institue
  • Indonesia > DKI Jakarta > Jakarta Barat > Palmerah > Kota Bambu Utara > Kota Bambu Utara II
View GitHub Profile
public class ApiConfig {
private static final String BASE_URL = "urlxxx/api/";
private static Retrofit retrofit;
public static Retrofit getClient(){
if (retrofit == null){
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
@kazuiains
kazuiains / ActivityOrFragment
Last active June 14, 2021 08:19
Upload File Android 11 (R). get URI Path
//check permission
private boolean checkPermission() {
if (SDK_INT >= Build.VERSION_CODES.R) {
return Environment.isExternalStorageManager();
} else {
int result = ContextCompat.checkSelfPermission(requireContext(), android.Manifest.permission.READ_EXTERNAL_STORAGE);
int result1 = ContextCompat.checkSelfPermission(requireContext(), android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
return result == PackageManager.PERMISSION_GRANTED && result1 == PackageManager.PERMISSION_GRANTED;
}
}