Skip to content

Instantly share code, notes, and snippets.

View virendersran01's full-sized avatar
💻
Working from home

Virender Srxn virendersran01

💻
Working from home
  • India
View GitHub Profile
@Override
public boolean shouldOverrideUrlLoading(WebView view, String authorizationUrl) {
//This method will be called when the Auth proccess redirect to our RedirectUri.
//We will check the url looking for our RedirectUri.
if (authorizationUrl.startsWith(REDIRECT_URI)) {
Log.i("Authorize", "");
Uri uri = Uri.parse(authorizationUrl);
//We take from the url the authorizationToken and the state token. We have to check that the state token returned by the Service is the same we sent.
//If not, that means the request may be a result of CSRF and must be rejected.
String stateToken = uri.getQueryParameter(STATE_PARAM);
...
bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(View view, int i) {
// ..
// your code is here
}
@Override
LinearLayout bottomSheet = findViewById(R.id.bottom_sheet_behavior_id);
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
// ..
// here you could find all the UI views inside your bottom sheet and initialize them
// ..
// ..
// setting the bottom sheet callback for interacting with state changes and sliding
bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
<?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"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/your_bottom_sheet_background"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
app:behavior_hideable="true"
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Intent intent = new Intent();
String packageName = getPackageName();
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
if (!pm.isIgnoringBatteryOptimizations(packageName)) {
intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
intent.setData(Uri.parse("package:" + packageName));
startActivity(intent);
}
}
final WifiManager wifimanager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
wifimanager.registerScanResultsCallback(getMainExecutor(), new WifiManager.ScanResultsCallback() {
@Override
public void onScanResultsAvailable() {
List<ScanResult> results = wifimanager.getScanResults();
for (ScanResult result : results) {
System.out.println(result.BSSID);
}
}
mLocationManager.removeTestProvider(LocationManager.GPS_PROVIDER);
mLocationManager.removeTestProvider(LocationManager.NETWORK_PROVIDER);
private void setMock(String provider, double latitude, double longitude) {
mLocationManager.addTestProvider (provider, false, false, false, false, false, true, true, 0, 5);
Location newLocation = new Location(provider);
newLocation.setLatitude(latitude);
newLocation.setLongitude(longitude);
newLocation.setAltitude(3F);
newLocation.setTime(System.currentTimeMillis());
newLocation.setSpeed(0.01F);
...
if (!isMockLocationEnabled)
startActivity(new Intent(android.provider.Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS));
...
private boolean isMockLocationEnabled()
{
boolean isMockLocation;
try {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// ':video' module gradle file.
dependencies {
implementation project(':app')
implementation project(':camera')
...
}