public void onClickApp(View view){
Intent intent = new Intent("android.intent.action.MAIN");
intent.setComponent(ComponentName.unflattenFromString("com.android.chrome/com.android.chrome.Main"));
intent.addCategory("android.intent.category.LAUNCHER");
intent.setData(Uri.parse("http://www.google.com"));
startActivity(intent);
}
This code open Google Chrome and open the web www.google.com.
On Android 5, only open Google Chrome but not load www.google.com.
why?
sorry for my bad english.
thanks
I think thats beacuse the activity doesn't exist in android lollipop.
Try with this:
public void onClickApp(View view){
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://www.google.com"));
intent.setPackage("com.android.chrome");
startActivity(intent);
}
Related
I have a scenario where it has to be tested when there is no connection. To automate this i thought making browser as offline and to test the scenario is feasible. Someone please help me how do we set browser offline during execution of a test from protractor? is there a way to access browser preferences from protractor ?
Since I don't see what language you are coding in I'm gonna assume it's Java
this func turns off the wifi:
protected void disConnectInternet() throws IOException {
Map map = new HashMap();
map.put("offline", true);
map.put("latency", 5);
map.put("download_throughput", 500);
map.put("upload_throughput", 1024);
CommandExecutor executor = ((ChromeDriver)driver).getCommandExecutor();
Response response = executor.execute(
new Command(((ChromeDriver)driver).getSessionId(), "setNetworkConditions", ImmutableMap.of("network_conditions", ImmutableMap.copyOf(map))));
}
I am using following code to open share UI. It opens all available share text sharing apps. Is there any way i can filter those share to Messaging and Whatsapp apps?
void dataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs e)
{
DataRequest request = e.Request;
request.Data.Properties.Title = "the title";
request.Data.Properties.Description = "description";
request.Data.Properties.ApplicationName = "Messeging";
request.Data.SetText(shareText);
}
No, this is the expected behaviour and all the apps who can read text will be shown.
I'm testing a web application on Chrome, Android (real device, not emulator) using Appium. Whenever I launch a test, all browser data (bookmarks, history etc.) is deleted. Is there any way to stop this from happening?
I tried setting the noReset capability to true, but that didn't help.
Thank you in advance for any help
public static Uri testServerAddress = new Uri("http://127.0.01:4723/wd/hub"); // Appium is running locally
public static TimeSpan INIT_TIMEOUT_SEC = TimeSpan.FromSeconds(180);
public void SetUpTest()
{
if (driver == null)
{
DesiredCapabilities testCapabilities = new DesiredCapabilities();
testCapabilities.SetCapability("browserName", "Chrome");
testCapabilities.SetCapability("platformName", "Android");
testCapabilities.SetCapability("deviceName", "S(Galaxy S5)");
testCapabilities.SetCapability("noReset", true);
AppUrl = "http://www.google.com/"; //for example
driver = new RemoteWebDriver(testServerAddress, testCapabilities, INIT_TIMEOUT_SEC);
driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, globalTimeoutInSec));
driver.Navigate().GoToUrl(AppUrl);
}
}
Chromedriver always starts totally fresh, nothing is keeping.
There is option to re-use the existent one (using desired capability androidUseRunningApp) but unfortunately Appium any way will kill it.
Please see more details in this post
At start I'm sorry for my English is poor. And this is the only place where i solved the problem.
I have a problem with my application. I write and test it on emulator in VisualStudnio 2012 and It work fine. But when I add aplication in WindowsPhone store and I get to phone. It crashed. I think that problem is in geolocator or something with GPS, because when i use function where my it don't use gps it work. Everywhere where i use geolocator_geopositionchanged it break down and app is terminate. in one of application page i use map control but i gave token and application id but only in class where i use map.
private void maping_Loaded(object sender, RoutedEventArgs e)
{
Microsoft.Phone.Maps.MapsSettings.ApplicationContext.ApplicationId = "id";
Microsoft.Phone.Maps.MapsSettings.ApplicationContext.AuthenticationToken = "token";
}
Do you have any sugestion or advices?
if you want watching app there is a link
http://www.windowsphone.com/pl-PL/store/app/opencaching/06bce1e1-16ef-4ebf-ac53-23b4c725f78b
I have geolocator in a few class it's one of them
Geolocator code
if (!tracking)
{
gps = new Geolocator();
gps.DesiredAccuracy = PositionAccuracy.High;
gps.ReportInterval = 100;
gps.PositionChanged += geolocator_PositionChanged;
}
else
{
gps.PositionChanged -= geolocator_PositionChanged;
gps = null;
}
tracking = !tracking;
Geoposition changed code
void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
{
double distance = 0;
distance = point.GetDistanceTo(new GeoCoordinate(args.Position.Coordinate.Latitude, args.Position.Coordinate.Longitude));
string asa = Convert.ToInt64(distance).ToString();
if (asa != null)
{
Dispatcher.BeginInvoke(() =>
{
TBodleglosc.Text = asa +"m";
navi.Rotation = 180 + Kierunek(point.Latitude, point.Longitude, args.Position.Coordinate.Latitude, args.Position.Coordinate.Longitude);
});
}
}
Debug on your device. If that cannot repro, setup a Beta Test app and use that to distribute the app back to yourself for debugging. Sometimes signing breaks things.
I debug at lumia 920 and I have a problem with convert.toDouble
because there are was , i have . and vice versa
I think that it's connected with phone language
because in english emulator and Ertay Shashko phone who debug it yesterday it's working fine.
At now application work at phone but doesn't at emulator.
but if i change settings on location and language apps work but I can't debug because visual studio have error
It's weird .....
I tried to create an app that opens some third party apps with the help of its Uri from a Tile. Well, it actually works in opening the third party apps but the problem is, first it launches my app(i.e MainPage is visible for a second) and then only it opens the respective app. Is there any way to make my app's MainPage invisible before opening an app or am i missing anything in Capabilities?
Here is my code :
IconicTileData iconicTileData1 = new IconicTileData();
iconicTileData1.Title = name;
iconicTileData1.SmallIconImage = new Uri("/Icons/Small.png", UriKind.Relative);
iconicTileData1.IconImage = new Uri("/Icons/Metro/" + name + "Medium.png", UriKind.Relative);
IconicTileData iconicTileData2 = iconicTileData1;
Uri navigationUri = new Uri("/MainPage.xaml?target=ms-settings-bluetooth:", UriKind.Relative);
ShellTile.Create(navigationUri, (ShellTileData)iconicTileData2, true);
Thanks in advance for your help.
You could try to specify a "custom" page target (instead of MainPage.xaml) and then make a UriMapper that will allow your app to redirect. Here is a nice blog post on creating a UriMapper. Here is some pseudo-code to help:
public class SettingsUriMapper : UriMapperBase
{
public override Uri MapUri(Uri uri)
{
if (uri.OriginalString.StartsWith == "/LaunchSettings.xaml")
{
// parse which settings to go to
// launch settings uri
}
return uri;
}
}