How do I open GPS settings in android? - android

I am trying to navigate to the geolocation settings page, however, I get an error "ACTION_LOCATION_SOURCE_SETTINGS cannot be resolved or is not a field" in my code. I have searched everywhere, but couldn't find anything different from what I have done already.-
startActivityForResult(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS), 1);
I am running Android 7.0. Is there any other way to do this on my android version?

I think you are using wrong import
Use the below import and remove the previous one
import android.provider.Settings;
Or you can also try like below.
Intent settingintent= new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(settingintent);

Related

Why react native can`t find image in assets folder?

I have a background image in src/assets folder which I try to get access to from src/screens/splash/index.js as such:
import {ImageBackground} from 'react-native';
import React from 'react';
export default function SplashScreen() {
return (
<ImageBackground
source={require('../../assets/bg1.jpg')}
resizeMode={'cover'}
style={{flex: 1}}>
</ImageBackground>
);
}
Returns this error:
None of these files exist:
bg1.jpg
src\assets\bg1.jpg\index(.native|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
If i move the image in any other folder, for example screens and change source to:
source={require('../../screens/bg1.jpg')}
its working fine.
Im baffled and wondering the reason behind it?
Is it maybe because I use react-native cli and renamed the tsx file created originally to js?
Here is a picture in case it helps understanding the problem.
After trying everyting was suggested in the comments, nothing has worked so far. I went ahead and continue building the app (following a tutorial) and re-compiled the application, now on an other computer and it started working!
The only change that I made since added the assets folder and the image that following the documentation integration-with-android-fragment I added few extra lines to MainActivity.java as suggested.
import android.os.Bundle;
and
private Bundle getLaunchOptions(String message) {
Bundle initialProperties = new Bundle();
initialProperties.putString("message", message);
return initialProperties;
}
Now im not 100% sure this was the solution to the problem, but I assume it must have been as no other changes has been made to the code since the error message appeared..
That is also possible that on my other computer it still wouldnt work, so the error is rooted somewhere within how my computer handeled these packadges. Unfortunately Im unable to test this theory for the next 2 weeks, but will share it whatever it concludes.

Appium Native View, how to click the button to go back to the previous screen

I am pretty new to Appium, using UIAutomator2. Following instructions on the links:
[https://discuss.appium.io/t/click-back-button-on-android-device-in-java/6817/3][1]
[https://discuss.appium.io/t/click-back-button-twice-in-android-7-using-appium-uiautomator2/20368][2]
[https://stackoverflow.com/questions/30801879/how-to-automate-the-android-phone-back-button-using-appium][3]
I have tried all the options offered in these articles:
driver.pressKeyCode(4);
helper.driver.pressKeyCode(187);
driver.back();
driver.navigate().back();
If I add the imports
import io.appium.java_client.android.nativekey.AndroidKey;
import io.appium.java_client.android.nativekey.KeyEvent;
and I try
driver.pressKeyCode(AndroidKeyCode.BACK);
Eclipse tells me that the method is undefined...
But none of them have worked. Is there anything I need to import or any additional classes I need to create? My driver only has methods for testing, such as close(), equals(), execute(), findElement()... but nothing like back(), or pressKeyCode() or navigate()(this one, probably, because it is not webView)... So, when I try to just type any of those methods, Eclipse either suggests to add a cast, or to create a class...
Please, Can anyone give me some more details on how to do it?
The driver should be an Appium driver. And try to run on real device than emulators.
driver = new AppiumDriver<>(url, desiredCapabilities);

React Native Android - development server response error code 500

Learning react-native and currently following IG clone tutorial on my android device from this youtube video - https://www.youtube.com/watch?v=cgg1HidN4mQ
I have come stuck in this. Attached image is something I've been trying to fix for hours with no luck...
https://imgur.com/a/u8Kmw
Does anybody know what would be the cause of this? Here is the code...
https://github.com/crt434/React_IG_Copy
See this code in your Mainscreen.js
import HomeTab from './AppTabNavigator/HomeTab'
import SearchTab from './AppTabNavigator/SearchTab'
import AddMediaTab from './AppTabNavigator/AddMediaTab'
import LikesTab from './AppTabNavigator/LikesTab'
import ProfileTab from './AppTabNavigator/ProfileTab'
All these paths are missing. there is no AppTabNavigator folder.

Android Studio import class shortcut

I've looked at How to auto import the necessary classes in Android Studio with shortcut? but it doesn't help.
Ctrl+Alt+O does nothing.
When I press alt+enter I get the following:
I do not want this, I wish for it to appear as a normal import at the top of the file.
What are these shortcuts called in Android Studio? This program makes it complicated to edit such simple shortcuts.
I also have auto-imports, but it isn't working:
Finally after hours of trail and error the following settings is what fixed it:
Pressing Ctrl + Space on Mac will open a dialog to choose which library to import.
check this link for detail ans
https://stackoverflow.com/a/37362700/3288890
or
goto file -> setting select keymap and search for auto import and add keyboard short cut

Phonegap Local Notification Plugin for Android

I'm working on a "Reminders" application on Android using Phonegap[Cordova 2.2].
The user enters a specific date for his reminder and I'm supposed to notify him on time.
I used this plugin to Just show a notification in the status bar & they are working fine.
But I want the notifications to show at specific times. Is there some method to do it ?
I found this plugin that's supposed to do what I want but it's not working, it shows errors at :
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;
The import com.phonegap.api.Plugin cannot be resolved
So, how can I fix this error ? I know it might be easy, but I never made native Android Apps before so I'm kind of confused.
Thanks
Looks like a difference between 2.0.0 and 2.2.0, and like the plugin needs updating.
import org.apache.cordova.api.CordovaPlugin;
import org.apache.cordova.api.PluginResult;
This should give you a jumping off point:
http://docs.phonegap.com/en/2.2.0/guide_plugin-development_android_index.md.html#Developing%20a%20Plugin%20on%20Android
For the new Phonegap Release you must also change some stuff:
The LocalNotification class must "extends CordovaPlugin" now
Import classes like eomer says
The execute method of LocalNotification.java must return a boolean now
Change all return arguments that are affected (from PluginResult) to boolean of your choice
Get the context in a new way ctx = this.cordova.getActivity(); and give it the ...AlarmHelper(ctx)

Categories

Resources