I'm developing a BB app where I need to use some custom fonts. I was trying to load them as "statics"
public class MyFontTool
{
public static FontFamily fontSolanoGothicMVBLt = Font.getDefault().getFontFamily();
try {
if (FontManager.getInstance().load("font/SolanoGothicMVB-Lt.ttf",
"SolanoGothicMVB-Lt", FontManager.APPLICATION_FONT) == FontManager.SUCCESS) {
fontSolanoGothicMVBLt = FontFamily
.forName("SolanoGothicMVB-Lt");
}
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
not sure if this is possible but when I run the application I got this message:
Error Starting ... : Class 'net.rim.device.api.ui.FontManager' not found.
I'm using Blackberry SDK 5.0
Any idea why this doesn't work?
Related
I am trying to use the MediaDevices library to download files from my phone. I am able to see the files on my phone, but MediaDevice.DownloadFile() throws a NotImplemented exception. I've got version 1.8.0 of the library. Here is my program:
using System;
using System.Diagnostics;
using System.IO;
using MediaDevices;
namespace ReadPhoneFile
{
class Program
{
static MediaDevice thePhone;
static void Main(string[] args)
{
var devices = MediaDevice.GetDevices();
foreach (MediaDevice device in devices)
{
try
{
thePhone = device;
device.Connect();
DownloadFiles(device, "e:/pictures/Rob's Test Phone/Lightroom");
device.Disconnect();
}
catch
{
// If it can't be read, don't worry.
}
}
Console.WriteLine("Press any key.");
Console.ReadKey();
}
static void DownloadFiles(MediaDevice device, string pcFolder)
{
var lightroomDir = device.GetDirectoryInfo(#"Phone\Android\data\com.adobe.lrmobile\files\carouselDocuments\a6f0275ee0b94c90b3c05f093250d4ef\Originals");
// ProcessLightroomFolder(photoDir, pcFolder, false);
foreach (MediaDirectoryInfo subFolder in lightroomDir.EnumerateDirectories())
{
ProcessLightroomFolder(subFolder, pcFolder, true);
}
}
static void ProcessLightroomFolder(MediaDirectoryInfo folder, string pcFolder, bool createFolder)
{
Console.WriteLine($"Processing folder {folder.Name} into folder {pcFolder}");
string pcSubFolder = $"{pcFolder}/{folder.Name}";
if (createFolder)
{
Directory.CreateDirectory(pcSubFolder);
}
foreach (MediaFileInfo file in folder.EnumerateFiles())
{
ProcessLightroomFile(file, pcSubFolder);
}
foreach (MediaDirectoryInfo subFolder in folder.EnumerateDirectories())
{
ProcessLightroomFolder(subFolder, pcSubFolder, true);
}
}
static void ProcessLightroomFile(MediaFileInfo file, string pcFolder)
{
Console.WriteLine($"Processing Lightroom file {file.Name} into folder {pcFolder}");
DownloadFile(file, pcFolder);
}
static void DownloadFile(MediaFileInfo phoneFile, string destinationFolder)
{
try
{
MemoryStream memoryStream = new System.IO.MemoryStream();
thePhone.DownloadFile(phoneFile.FullName, "c:/misc/downloadedFile.dng");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
there is an issue raised on github to solve this problem (https://github.com/Bassman2/MediaDevices/issues/32). The problem is that you are building your app on top of .NET Core 3.1, and this lib works well on .NET Framework 4.* as they warn when you build your project:
Package 'MediaDevices 1.8.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.1'. This package may not be fully compatible with your project
A Simple question for every one , is there any possible way to get Blackberry BBM Logs in application , via Programming.
Following task I have done :-
Download & integrate BBM SDK in Project.
Follow the BBM Development Guide.
Here are My Code :-
public void getBBM_Logs()
{
BBMPlatformContext platformContext =null;
try
{
platformContext = BBMPlatformManager.register(new MyBBMAppPlugin());
if(platformContext != null)
{
ContactListService contactListService = platformContext.getContactListService();
BBMPlatformContactList contacts = contactListService.getContactList();
Enumeration contactsEnum = contacts.getAll();
while(contactsEnum.hasMoreElements())
{
BBMPlatformContact contact = (BBMPlatformContact)contactsEnum.nextElement();
add(new LabelField(contact.getDisplayName()));
}
}
}
catch (ControlledAccessException e)
{
// The BBM platform has been disabled
}
if (platformContext != null)
{
MyBBMPlatformContextListener platformContextListener;
platformContextListener = new MyBBMPlatformContextListener();
platformContext.setListener(platformContextListener);
}
}
private class MyBBMPlatformContextListener extends BBMPlatformContextListener
{
public void accessChanged(boolean isAccessAllowed, int accessErrorCode)
{
if (!isAccessAllowed)
{
// You cannot access the BBM platform
}
}
public void appInvoked(int reason, Object param)
{
// Code for handling different contexts for invocation
}
}
private class MyBBMAppPlugin extends BBMPlatformApplication
{
public MyBBMAppPlugin()
{
super("57888721-1e52-4171-a8a4-0559eab8efdf");
}
}
Please Let Me know , is there any possible way to get ChatLogs.
Sorry this is not possible - as I think BB regard access to chat logs from a program as a potential security exposure.
I'm implementing a Filepicker in my app to allow users to choose photos from their phones. The code I'm using is as follows:
Calling the Filepicker:
try
{
UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run()
{
FilePicker fp = FilePicker.getInstance();
fileListener = new FilePickListener();
fp.setListener(fileListener);
fp.show();
}
});
}
catch (Exception e)
{
UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run()
{
Dialog.alert("Please check your data card..");
}
});
}
And the method to get the filename in my FilePickListener:
public void selectionDone(String str)
{
this.currFileName = str;
int index = str.lastIndexOf('/');
Dialog.alert("Filename: "+str.substring(index+1).trim());
}
This works perfectly in most handsets that I've tried it on (which have been a mix of handsets with some running OS5 and some running OS6). But on some, like the 8900 (running OS v5.0.0.411) it doesn't work properly. The Filepicker gets called and appears, but when any file gets selected, the selectionDone method doesn't get called. I've tested it on two separate 8900s and both have the same problem.
Does anyone have an idea why it works on certain handsets and not other?
You are a victim of a known RIM issue: FilePicker throws ControlledAccessException.
The issue is marked as "Fixed". However there is no info in which OS version they fixed it. (Is it so difficult to tell such a useful info?)
But from the comments to the issue:
We experience the very same issue with OS 5.0.0.321 on a Bold 9700. However, the issue does NOT appear on OS 5.0.0.464
so my guess would be they fixed it in OS 5.0.0.464. But that's not the end - in OS 6 FilePicker appears broken in early versions of OS 6 again. The conclusion - just don't use it. Use a custom file browser screen to pick a file. There is a sample in SDK 4.7.0 named FileExplorerDemo, check it for implementation details.
This is a known issue. FilePicker does not open on some devices and return an error, like the 8900 device. You can catch this error on some devices by adding the catch (Error e) { }
UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run()
{
FilePicker fp = FilePicker.getInstance();
fileListener = new FilePickListener();
fp.setListener(fileListener);
fp.show();
}
});
}
catch (Exception e)
{
UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run()
{
Dialog.alert("Please check your data card..");
}
});
}
catch (Error e)
{
UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run()
{
Dialog.alert("This device does not support File Picker");
}
});
}
I want to show malayalam script in my application in blackberry 5.0.i tried with following code. but it shows text in english only.
try {
alphaSerifFamily = FontFamily.forName("BBAlpha Serif");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Font appFont = alphaSerifFamily.getFont(Font.MALAYALAM_SCRIPT, 9, Ui.UNITS_pt);
setFont(appFont);
Check the following links:
http://yamspog.wordpress.com/2009/08/30/how-to-use-resource-files-in-your-blackberry-app/
http://docs.blackberry.com/en/developers/deliverables/12002/Create_resource_file_for_BlackBerry_Application_655978_11.jsp
When done with creating the ressource files, use the following code to retrieve the KEY value:
public static ResourceBundle _res = ResourceBundle.getBundle(BUNDLE_ID, BUNDLE_NAME);
_res.getString(yourKey)
I created app which user can start from menu and from icon. I do not use GlobalEventListener in my app, just register ApplicationMenuitem. And now I am getting error: previous instance still active when launch my app.
Steps to reproduce not so trivial:
launch app from icon
do not close it, just switch to another app
launch app from icon again
I founded article in blackberry's forum about it , but I can't find solution where I should remove my ApplicationMenuItem: it added on phone boot and should show all the time.
My code:
public class Jingu extends UiApplication {
public static void main(String[] args) {
ApplicationManager app = ApplicationManager.getApplicationManager();
boolean keepGoing = true;
while (keepGoing) {
if (app.inStartup()) {
try {
Thread.sleep(1000);
} catch (Exception e) {}
} else {
keepGoing = false;
}
}
Jingu theApp = new Jingu();
theApp.initMenuItem();
theApp.showMainScreen();
theApp.enterEventDispatcher();
}
public Jingu() {
}
public void showMainScreen() {
showScreen(new JinguMainScreen(this));
}
public void initMenuItem() {
// Create menu item
Object o = RuntimeStore.getRuntimeStore().get(JinguMenuItem.MY_MENU_ID);
// register only if not done already.
if (o == null) {
new JinguMenuItem(this).registerInstance();
}
}
public void showScreen(Screen aScreen) {
synchronized (Application.getEventLock()) {
try {
UiApplication.getUiApplication().popScreen(aScreen);
} catch (Exception e) {
}
UiApplication.getUiApplication().pushScreen(aScreen);
}
}
}
public class JinguMenuItem extends ApplicationMenuItem {
public static final long MY_MENU_ID = 0xb9739d5240d5943dL;
private final Jingu jingu;
public JinguMenuItem(Jingu jingu) {
super(0x350100);
this.jingu = jingu;
}
public void registerInstance() {
Object menuItem = RuntimeStore.getRuntimeStore().remove(MY_MENU_ID);
if (menuItem == null) {
ApplicationMenuItemRepository amir = ApplicationMenuItemRepository.getInstance();
amir.addMenuItem(ApplicationMenuItemRepository.MENUITEM_SYSTEM, this);
RuntimeStore.getRuntimeStore().put(MY_MENU_ID, this);
}
}
public Object run(Object context) {
jingu.setDefaultFont(Font.getDefault());
jingu.setMainApp(false);
jingu.setBbmEditField(null);
jingu.showMainScreen();
return context;
}
public String toString() {
return "My Menu";
}
}
plz advice where I should delete ApplicationMenuItem in my app?
my regards,
Vadim
If you are registering an ApplicationMenuItem from your application, as a user I would consider it bad style for your application to remove and exit, even if RIM provided a way to do this. You may want to separate your application into two parts. One provides the minimal support for responding to the ApplicationMenuItem selection, that starts automatically and runs in the background. The other has all the rest and can run and exit as needed.
My solution for this situation is:
create alternative entry point and run it on app load
register menu in it
do not use runtimeStore