This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PermissionManager { | |
private Context context; | |
private SessionManager sessionManager; | |
public PermissionManager(Context context){ | |
this.context = context; | |
sessionManager = new SessionManager(context); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
configurations.all { | |
resolutionStrategy.eachDependency{ | |
DependencyResolveDetails details -> | |
def requested=details.requested | |
if(requested.group=="com.android.support"){ | |
if(!requested.name.startsWith("multidex")){ | |
details.useVersion("26.0.1") | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String getInBangla(String string) | |
{ | |
Character bangla_number[]={'১','২','৩','৪','৫','৬','৭','৮','৯','০'}; | |
Character eng_number[]={'1','2','3','4','5','6','7','8','9','0'}; | |
String values = ""; | |
char[] character = string.toCharArray(); | |
for (int i=0; i<character.length ; i++) { | |
Character c = ' '; | |
for (int j = 0; j < eng_number.length; j++) { | |
if(character[i]==eng_number[j]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ApiClient { | |
public static final String BASE_URL = "http://api.themoviedb.org/3/"; | |
private static Retrofit retrofit = null; | |
public static Retrofit getClient() { | |
if (retrofit==null) { | |
retrofit = new Retrofit.Builder() | |
.baseUrl(BASE_URL) | |
.addConverterFactory(GsonConverterFactory.create()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | |
super.onRequestPermissionsResult(requestCode, permissions, grantResults); | |
switch (requestCode) { | |
case REQUEST_CAMERA: { | |
// If request is cancelled, the result arrays are empty. | |
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | |
//Permission was granted. Now you can call your method to open camera, fetch contact or whatever | |
openCamera(); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean hasPermission(String permission) { | |
return ContextCompat.checkSelfPermission(getApplicationContext(), permission) == PackageManager.PERMISSION_GRANTED; | |
} | |
public void askForMultiplePermissions(){ | |
final int REQUEST_CODE = 13; | |
String cameraPermissin = Manifest.permission.CAMERA; | |
String readContactsPermission = Manifest.permission.READ_CONTACTS; | |
String readExternalStoragePermission = Manifest.permission.READ_EXTERNAL_STORAGE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (ContextCompat.checkSelfPermission(thisActivity,Manifest.permission.READ_CONTACTS)!= PackageManager.PERMISSION_GRANTED) { | |
if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity, | |
Manifest.permission.READ_CONTACTS)) { | |
// Show an expanation to the user | |
} else { | |
if(isFirstTimeAsking(thisActivity, Manifest.permission.READ_CONTACTS){ | |
firstTimeAsking(thisActivity,Manifest.permission.READ_CONTACTS, false); | |
ActivityCompat.requestPermissions(thisActivity,new String[]{Manifest.permission.CAMERA}, REQUEST_CAMERA); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity implements View.OnClickListener { | |
private PermissionManager permissionManager; | |
private Button openCameraButton; | |
private ImageView imageView; | |
private final int REQUEST_CAMERA = 13; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.fabric.sdk.android.Fabric; | |
import com.crashlytics.android.Crashlytics; | |
public class MainActivity extends Activity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
OlderNewer