I am using the following code to invoke Google map in my simulator. i have already installed Google map in my simulator.
int mh = CodeModuleManager.getModuleHandle("GoogleMaps");
if(mh > 0) {
try{
URLEncodedPostData uepd = new URLEncodedPostData(null, false);
uepd.append("action","LOCN");
uepd.append("a", "#latlon:"+lat+","+log);
uepd.append("title","Stanford University School of Medicin");
uepd.append("description", "XYZ");
String[] args = { "http://gmm/x?"+uepd.toString() };
ApplicationDescriptor ad = CodeModuleManager.getApplicationDescriptors(mh)[0];
ApplicationDescriptor ad2 = new ApplicationDescriptor(ad, args);
ApplicationManager.getApplicationManager().runApplication(ad2, true);
}catch(Exception e){
System.out.println(e+"Excepton");
}}}
but i am getting a white screen , when i am pressing the menu button RUN GMAPS option is their. but when i am pressing the RUN GMAPS then also result is same only white screen is coming. i don't why it is coming. some one please help me out
i also want to Know. how to pin multiple places in google map.
thanks in advance
i think you should use kml file.
BrowserSession visit = Browser.getDefaultSession();
visit.displayPage("http://www.geochemie.uni-bremen.de/kml/borabora.kml");
you can test on simulator also.
Related
i'm using an Iphone 10 with ios 15.3.1,Zxing version = 2.4.1, compiling the xamarin project in windows. I been trying to make a qr scanner with zxing for ios android, but when i run my app in ios, it won't go to the onResult event. I've tried with a lot of methods of doing this, but nothing seems to work. The camera shows, but the result never comes truh. ¿Does someone have any idea why this is happening? I also tried apps from other devs that are using zxing and it also dosen't work. but when i scan with the camera app it works.
async void OnButtonClickedAsync(object sender, System.EventArgs e)
{
var options = new ZXing.Mobile.MobileBarcodeScanningOptions
{
CameraResolutionSelector = HandleCameraResolutionSelectorDelegate
};
MobileBarcodeScanner scanner = new MobileBarcodeScanner();
//scanner.TopText = "Hold camera up to barcode to scan";
//scanner.BottomText = "Barcode will automatically scan";
//scanner.UseCustomOverlay = false;
scanner.FlashButtonText = "Flash";
scanner.CancelButtonText = "Cancel";
scanner.Torch(true);
scanner.AutoFocus();
var result = await scanner.Scan(options);
HandleScanResult(result);
}
void HandleScanResult(ZXing.Result result)
{
if (result != null && !string.IsNullOrEmpty(result.Text))
scanResultText.Text = result.Text;
}
CameraResolution HandleCameraResolutionSelectorDelegate(List<CameraResolution> availableResolutions)
{
//Don't know if this will ever be null or empty
if (availableResolutions == null || availableResolutions.Count < 1)
return new CameraResolution() { Width = 800, Height = 600 };
//Debugging revealed that the last element in the list
//expresses the highest resolution. This could probably be more thorough.
return availableResolutions[availableResolutions.Count - 1];
}
I compiled using a mac and it worked fine, must be a bug of visual studio on windows.
With the help of this question I was able to figure out how I can display a link inside a StyledText widget in SwT. The color is correct and even the cursor changes shape when hovering over the link.
So far so good, but the link is not actually clickable. Although the cursor changes its shape, nothing happens if clicking on the link. Therefore I am asking how I can make clicking the link to actually open it in the browser.
I thought of using a MouseListener, tracking the click-location back to the respective text the click has been performed on and then deciding whether to open the link or not. However that seems way too complicated given that there already is some routine going on for changing the cursor accordingly. I believe that there is some easy way to do this (and assuring that the clicking-behavior is actually consistent to when the cursor changes its shape).
Does anyone have any suggestions?
Here's an MWE demonstrating what I have done so far:
public static void main(String[] args) throws MalformedURLException {
final URL testURL = new URL("https://stackoverflow.com/questions/1494337/can-html-style-links-be-added-to-swt-styledtext");
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1, true));
StyledText sTextWidget = new StyledText(shell, SWT.READ_ONLY);
final String firstPart = "Some text before ";
String msg = firstPart + testURL.toString() + " some text after";
sTextWidget.setText(msg);
sTextWidget.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
StyleRange linkStyleRange = new StyleRange(firstPart.length(), testURL.toString().length(), null, null);
linkStyleRange.underline = true;
linkStyleRange.underlineStyle = SWT.UNDERLINE_LINK;
linkStyleRange.data = testURL.toString();
sTextWidget.setStyleRange(linkStyleRange);
shell.open();
while(!shell.isDisposed()) {
display.readAndDispatch();
}
}
Okay I was being a little too fast on posting this question... There's a snippet that deals with exactly this problem and it shows, that one indeed has to use an extra MouseListener in order to get things working.
The snippet can be found here and this is the relevant part setting up the listener:
styledText.addListener(SWT.MouseDown, event -> {
// It is up to the application to determine when and how a link should be activated.
// In this snippet links are activated on mouse down when the control key is held down
if ((event.stateMask & SWT.MOD1) != 0) {
int offset = styledText.getOffsetAtLocation(new Point (event.x, event.y));
if (offset != -1) {
StyleRange style1 = null;
try {
style1 = styledText.getStyleRangeAtOffset(offset);
} catch (IllegalArgumentException e) {
// no character under event.x, event.y
}
if (style1 != null && style1.underline && style1.underlineStyle == SWT.UNDERLINE_LINK) {
System.out.println("Click on a Link");
}
}
}
});
I am trying to add a list in a VerticalFieldManager and then that manager to another VerticalFieldManager. I am using it in custom tabs.First time when application starts it runs fine but when I switch to another tab and return to same it gives IllegalStateException.
I tried it in many ways but not getting what is causing the exception in adding that VerticalFieldManager.
I am using the code :
//HEADER
_bitmap = EncodedImage.getEncodedImageResource("Friends.png");
friendsBmp = new BitmapField(Constants.sizePic(_bitmap, _bitmap.getHeight(), _bitmap.getWidth()));
//add(WebBitmapField.getUrlHFM());
SCREEN_FLAG = Constants.FRIENDS_FLAG ;
//FRIENDS' UPPER TAB
friendsTabHFM =new HorizontalFieldManager();
Bitmap ConnectedUser_normal_Bmp =Constants.sizePic(EncodedImage.
getEncodedImageResource("connected_user_normal.png"),40, Display.getWidth()/2); //Bitmap.getBitmapResource("connected_user_normal.png");
Bitmap search_normal_Bmp = Constants.sizePic(EncodedImage.
getEncodedImageResource("search_normal.png"),40, Display.getWidth()/2);//Bitmap.getBitmapResource("search_normal.png");
Bitmap ConnectedUser_tap_Bmp = Constants.sizePic(EncodedImage.
getEncodedImageResource("connected_user_tap.png"),40, Display.getWidth()/2);//Bitmap.getBitmapResource("connected_user_tap.png");
Bitmap search_tap_Bmp = Constants.sizePic(EncodedImage.
getEncodedImageResource("search_tap.png"),40, Display.getWidth()/2);//Bitmap.getBitmapResource("search_tap.png");
connectedUsersTab= new CustomButtonField(ConnectedUser_normal_Bmp.getWidth(), "", ConnectedUser_normal_Bmp, ConnectedUser_tap_Bmp, ButtonField.FIELD_HCENTER );
connectedUsersTab.setChangeListener(this);
searchTab = new CustomButtonField(search_normal_Bmp.getWidth(), "", search_normal_Bmp, search_tap_Bmp, ButtonField.FIELD_RIGHT);
searchTab.setChangeListener(this);
friendsTabHFM.add(connectedUsersTab);
friendsTabHFM.add(searchTab);
if(Constants.isGetConnectedFriends){
Constants.isGetConnectedFriends =false ;
if(friendsVFM.getFieldCount()!= 0){
friendsVFM.deleteAll();
}
//GET CONNECTED FRIENDS WEB SERVICE CALL
GetConnectedFriendsInterMediater getConnectedFriendsInterMediater = new GetConnectedFriendsInterMediater(WebServiceDetails.METHOD_GET_CONNECTED_USER, Jxa.loginUserName);
PleaseWaitPopupScreen.showScreenAndWait(getConnectedFriendsInterMediater, Constants.PLEASE_WAIT_TEXT);
}else if(Constants.isGetUserByUsername){
//Constants.isGetUserByUsername = false ;
GetUserByUsernameIntermediator getUserListIntermediator=new GetUserByUsernameIntermediator(Jxa.loginUserName ,SearchUserScreen.userName);
PleaseWaitPopupScreen.showScreenAndWait(getUserListIntermediator, Constants.PLEASE_WAIT_TEXT);
}else if(Constants.isGetAllUser){
Constants.isGetAllUser = false ;
GetAllUserListIntermediator getAllUserListIntermediator=new GetAllUserListIntermediator(WebServiceDetails.METHOD_FIND_USERS,SearchUserScreen._ageRange,SearchUserScreen._status,SearchUserScreen._religion,String.valueOf(SearchUserScreen._page) ,Jxa.loginUserName);
PleaseWaitPopupScreen.showScreenAndWait(getAllUserListIntermediator, Constants.PLEASE_WAIT_TEXT);
}
if(_mainScreenVFM.getFieldCount()!=0){
_mainScreenVFM.deleteAll();
}
_mainScreenVFM.add(friendsTabHFM);
_mainScreenVFM.add(friendsVFM);
These code is for a tab in which two sub-tabs are there.For sub tabs it is running fine but for not for main tab.
One more scenario is there,when GetConnectedFriendsInterMediater is called in that I am adding the list in friendsVFM which creating the exception.
Code for that is:
GetConnectedFriendsWebService getFriendsWebService = new GetConnectedFriendsWebService(method ,userName);
Vector friendsVecList= getFriendsWebService.getFriends();
Constants.connectedUsersVector = friendsVecList ;
synchronized (UiApplication.getEventLock()) {
if(TabControlScreen.friendsVFM.getFieldCount()!=0){
TabControlScreen.friendsVFM.deleteAll();
}
TabControlScreen.friendsVFM.add(ConnectedFriends.getInstance(KingdomConnectMain.buddyList)); //HERE LIST IS ADDED
}
I have resolved the problem ,when I was switching the tab ,I was not creating new instance for friendsVFM and using the same instance which was causing the exception at that time.Now ,same exception is thrown when I am trying to add buddyList in _listVFM . I know it is due to adding the buddyList again which is already added.Is there any solution so that I can add the list without exception. Code for that:
//CREATING SINGLETON REFERENCE OF THE BUDDYLIST SCREEN
public static ConnectedFriends getInstance(BuddyListField buddyListField){
if(connectedFriends==null){
connectedFriends = new ConnectedFriends(buddyListField);
}
return connectedFriends;
}
public ConnectedFriends(BuddyListField buddyListField) {
if(_listVFM!=null){
_listVFM.deleteAll();
}
_listVFM = new VerticalFieldManager();
_listVFM.add(buddyListField);//HERE IS EXCEPTION ,BUT WANT TO ADD THE LIST //SECOND TIME TOO
}
When I am returning from another tab to sam tab it throws exception or in other words I am not able to add the list.
Illegal state exception occurs when you're trying to add fields twice as suggested by Signare also. I guess you should try this first:
friendsVFM.getManager().delete(friendsVFM);
I solved it by using getManager() on buddyList and removing that.Than again I added it as per requirement and it worked.Code for this :
if(ConnectedFriends.getInstance(KingdomConnectMain.buddyList).getManager()!= null){
ConnectedFriends.getInstance(KingdomConnectMain.buddyList).getManager().delete(ConnectedFriends.getInstance(KingdomConnectMain.buddyList));
}
TabControlScreen.friendsVFM.add(ConnectedFriends.getInstance(KingdomConnectMain.buddyList));
This code is used while calling GetConnectedFriendsWebService in the second part of codes.
I have used following code to call Google Maps which is installed in Blackberry device
public void invokeGMaps(GMLocation l) {
URLEncodedPostData uepd = new URLEncodedPostData(null, false);
uepd.append("action", "LOCN");
uepd.append("a",
"#latlon:" + l.getLatitude() + "," + l.getLongitude());
uepd.append("title", l.getName());
uepd.append("description", l.getDescription());
String[] args = { "http://gmm/x?" + uepd.toString() };
ApplicationDescriptor ad = CodeModuleManager.getApplicationDescriptors(mh)[0];
ApplicationDescriptor ad2 = new ApplicationDescriptor(ad, args);
try {
ApplicationManager.getApplicationManager().runApplication(ad2, true);
} catch (ApplicationManagerException e) {
System.out.println(e.getMessage());
Dialog.alert("error1 " + e.getMessage());
} catch (Exception e) {
Dialog.alert("error2 " + e.getMessage());
}
}
this is working fine. I have passed current postion to it.
Suppose user will search any particular location on google maps after going on google maps. so while returning back to application i want searched location latitude & longitude from google maps.
So please give me idea how i will get it in my application from google maps application?
Please help me, or any help regarding search location on blackberry how to done it?
Thanks for reading my question patiently.
In my balckberry application i am using the Persistance,List and Threads to execute the code.
The code is given below:
enter code here
UiApplication.getUiApplication().invokeLater(new Runnable(){
public void run(){
CategoryListScreen.getInstance(
UiApplication.getUiApplication())
.setCategoryListContent();
}
});
public void setCategoryListContent() {
categoryList.delete(0);
CategoryListScreen categoryListScreen = CategoryListScreen
.getInstance(UiApplication.getUiApplication());
PersistentObject categoryListPersistObject = PersistentStore
.getPersistentObject(0x73c8d3592648fea5L);
PersistentObject datePersistObject = PersistentStore
.getPersistentObject(0xe453c1c0c14b9aebL);
categoryListPersistObject.setContents(Communicator.categoryDatas);
datePersistObject.setContents(new Date());
categoryListScreen.setCategoryListVector(new Vector());
categoryDataList = Communicator.categoryDatas;
System.out.println("-------------------- " + Communicator.categoryDatas.length);
for (int i = 0; i < Communicator.categoryDatas.length; i++) {
if (Communicator.categoryDatas[i] != null) {
if (Communicator.categoryDatas[i].getName() != null) {
categoryListScreen.getCategoryListVector().addElement(
Communicator.categoryDatas[i].getName());
}
}
}
testListCallback = new ListCallback();
categoryList.setCallback(testListCallback);
int i = categoryListScreen.getCategoryListVector().size();
categoryListScreen.getCategoryList().setSize(i);
System.out.println("---------------------->" + categoryListScreen.getCategoryListVector().size());
//
categoryListScreen.getCategoryList().setRowHeight(40);
// categoryListScreen.invalidate();
invalidate();
System.out.println("End.........................");
}
The application is Using the Threads to execute the persistance and also setting the size of the list.The application is running fine and exiting successfully.
But at the time of unistalling the application the device get being restarted and also after restarting the application ,there is no effect on the application.The application still remains there.
what is the problem in uinstalling the application which uses Threads,persistance and list?
why is it being restarted without any user confirmation or alert?
why is it not get being uninsall after restart?
please give the resolution for the given problem or any useful code snippet ,which would be appreciated.
Thanks,
Mishal Shah
Is this on a device simulator or a real device? As far as I know, if you reset the simulator, it loads back all the installed apps onto to simulator.