How to get package name using blackberry - blackberry

I am new to blackberry development, Is it possible to get package name of the application which is installed in device. I din't get any reference for this.
int[] handle = codeModuleManager.getModuleHandles();
for(int i=0; i<handle.length; i++){
ApplicationDescriptor[] app_descriptors = CodeModuleManager.getApplicationDescriptors(handle[i]);
if(app_descriptors != null){
System.out.println("app_descriptors length "+ app_descriptors.length);
for(int j=0; j< app_descriptors.length; j++){
System.out.println("Iterating the arraylist :: "+ app_descriptors[j].toString());
}
}
}

Try this -
This will get all the installed modules.
int[] v=net.rim.device.api.system.CodeModuleManager.getModuleHandles();
For getting the ApplicationDescriptors associated with the module, use the following code -
net.rim.device.api.system.CodeModuleManager.getApplicationDescriptors(int moduleHandle)
Edit : -
int[] handle = CodeModuleManager.getModuleHandles();
for(int i=0; i<handle.length; i++){
ApplicationDescriptor[] app_descriptors = CodeModuleManager.getApplicationDescriptors(handle[i]);
if(app_descriptors != null){
System.out.println("app_descriptors length "+ app_descriptors.length);
for(int j=0; j< app_descriptors.length; j++){
String moduleName = app_descriptors[i].getModuleName();
String name = app_descriptors[i].getName();
}
}
}

Related

Tesseract OCR iOS with MICR data return Exception on configEngine

I'm trying to get MICR numbers from an image using Tesseract OCR. I have mcr.traineddata which I get from below link. I put it inside tessdata folder and delete everything about eng and other languages.
https://github.com/BigPino67/Tesseract-MICR-OCR
I'm declaring Tesseract and process image with below code
if let tesseract = G8Tesseract(language: "mcr") {
tesseract.engineMode = .tesseractCubeCombined
tesseract.pageSegmentationMode = .auto
tesseract.image = image.g8_blackAndWhite()
tesseract.recognize()
textView.text = tesseract.recognizedText
}
However, It gives
other_case < unicharset_size:Error:Assert failed:in file unicharset.cpp, line 869
error from G8Tesseract.mm file inside TesseractOCRiOS framework. Below is the function and It gives error on int returnCode = _...... line. I guess It is something about being UTF8String because I'm trying to OCR MICR. However, I don't know how to solve it.
- (BOOL)configEngine
{
GenericVector<STRING> tessKeys;
for( NSString *key in self.configDictionary.allKeys ){
tessKeys.push_back(STRING(key.UTF8String));
}
GenericVector<STRING> tessValues;
for( NSString *val in self.configDictionary.allValues ){
tessValues.push_back(STRING(val.UTF8String));
}
int count = (int)self.configFileNames.count;
const char **configs = count ? (const char **)malloc(sizeof(const char *) * count) : NULL;
for (int i = 0; i < count; i++) {
configs[i] = ((NSString*)self.configFileNames[i]).UTF8String;
}
int returnCode = _tesseract->Init(self.absoluteDataPath.UTF8String, self.language.UTF8String,
(tesseract::OcrEngineMode)self.engineMode,
(char **)configs, count,
&tessKeys, &tessValues,
false);
if (configs != nullptr) {
free(configs);
}
return returnCode == 0;
}
Example of what I try to OCR:

MQL4 code limiting number of open symbols

I am trying to create an expert advisor ( EA ) that would limit the number of open symbol to 3
For example, if I load the EA on 15 different symbols, it would not open a trade on more than 3 at any particular time. Below is the code I inserted in the EA but not working as I want:
int SYMBOL_NUMBER_LIMIT = 3;
string COUNTED_SYMBOLS[];
ArrayResize(COUNTED_SYMBOLS, SYMBOL_NUMBER_LIMIT, 0);
for(int s=0; s<SYMBOL_NUMBER_LIMIT; s++) COUNTED_SYMBOLS[s]="";
int SYMBOLS_IN_TRADE_SO_FAR = 0;
bool NEW_TRADE_PERMISSION = true;
int ALL_POSITIONS = OrdersTotal(); // PositionsTotal();
if(ALL_POSITIONS > 0)
{
for(int index=0; index<ALL_POSITIONS; index++)
{
string THIS_SYMBOL = OrderSymbol(); // PositionGetSymbol(index);
bool Symbol_already_counted = false;
for(int i=0; i<SYMBOL_NUMBER_LIMIT; i++)
{
if(COUNTED_SYMBOLS[i]==THIS_SYMBOL)
{
Symbol_already_counted = true;
break;
}
if(Symbol_already_counted) continue;
else
{
SYMBOLS_IN_TRADE_SO_FAR++;
if(SYMBOLS_IN_TRADE_SO_FAR >= SYMBOL_NUMBER_LIMIT)
{
NEW_TRADE_PERMISSION = false;
break;
}
for(int j=0; j<SYMBOL_NUMBER_LIMIT; j++)
if(COUNTED_SYMBOLS[j]=="")
{
COUNTED_SYMBOLS[j] = THIS_SYMBOL;
break;
}
}
}
}
}
I would appreciate any help to make it work as I described. Thanks in advance

JavaCV Display image in color from video capture

I have trouble with display image from camera. I using VideoCapture and when I try display image in grayscale it's works perfect, but when I try display image in color that I get something like that:
link
Part of my source code:
public void CaptureVideo()
{
VideoCapture videoCapture = new VideoCapture(0);
Mat frame = new Mat();
while (videoCapture.isOpened() && _canWorking)
{
videoCapture.read(frame);
if (!frame.empty())
{
Image img = MatToImage(frame);
videoView.setImage(img);
}
try { Thread.sleep(33); } catch (InterruptedException e) { e.printStackTrace(); }
}
videoCapture.release();
}
private Image MatToImage(Mat original)
{
BufferedImage image = null;
int width = original.size().width(), height = original.size().height(), channels = original.channels();
byte[] sourcePixels = MatToBytes(original, width, height, channels);
if (original.channels() > 1)
{
image = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
}
else
{
image = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);
}
final byte[] targetPixels = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();
System.arraycopy(sourcePixels, 0, targetPixels, 0, sourcePixels.length);
return SwingFXUtils.toFXImage(image, null);
}
private byte[] MatToBytes(Mat mat, int width, int height, int channels)
{
byte[] output = new byte[width * height * channels];
UByteRawIndexer indexer = mat.createIndexer();
int i = 0;
for (int j = 0; j < mat.rows(); j ++)
{
for (int k = 0; k < mat.cols(); k++)
{
output[i] = (byte)indexer.get(j,k);
i++;
}
}
return output;
}
Anyone can tell me what I doing wrong? I'm new in image processing and I don't get why it's not working.
Ok. I resolve this.
Solution:
byte[] output = new byte[_frame.size().width() * _frame.size().height() * _frame.channels()];
UByteRawIndexer indexer = mat.createIndexer();
int index = 0;
for (int i = 0; i < mat.rows(); i ++)
{
for (int j = 0; j < mat.cols(); j++)
{
for (int k = 0; k < mat.channels(); k++)
{
output[index] = (byte)indexer.get(i, j, k);
index++;
}
}
}
return output;

STM32L-Discovery error message?

I'm trying to program a stm32l-discovery board and have come across this error that keeps appearing when I try to build my project.
error: #29: expected an expression
for (int i = 0; i <999; i++){
I'm using Keil uVision 4.
Source:
while (1) {
////fade up
int i = 0;
for (int i = 0; i <999; i++) {
TIM_SetCompare2(TIM2,i);
////Pulse width is set with this function
delay(100);
//// the '2' relates to the channel in use
}
}
Anyone know what this means?

Read kABPersonHomePageLabel from contact

I'm trying to access the homepages/websites from the users contacts on a iPad. I'm actually trying to modify an existing script that is used as a Native Extension for Adobe Air - https://github.com/memeller/ContactEditor/blob/master/ContactEditorXCode/ContactEditor.m
I'm very new to Objective-C/xCode so I'm really struggling get this extra field returned... Please can you someone help me out.
FREObject homepagesArray = NULL;
FRENewObject((const uint8_t*)"Array", 0, NULL, &homepagesArray, nil);
ABMultiValueRef homepages = ABRecordCopyValue(person, kABPersonHomePageLabel);
if(homepages)
{
for (CFIndex k=0; k < ABMultiValueGetCount(homepages); k++) {
NSString* homepage = (__bridge NSString*)ABMultiValueCopyValueAtIndex(homepages, k);
DLog(#"Adding homepage: %#",homepage);
FRENewObjectFromUTF8(strlen([homepage UTF8String])+1, (const uint8_t*)[homepage UTF8String], &retStr);
FRESetArrayElementAt(homepagesArray, k, retStr);
//[email release];
}
CFRelease(homepages);
FRESetObjectProperty(contact, (const uint8_t*)"homepages", homepagesArray, NULL);
}
else
FRESetObjectProperty(contact, (const uint8_t*)"homepages", NULL, NULL);
retStr=NULL;
You're using the wrong identifier for extracting ABMultiValueRef homepages. Use the kABPersonURLProperty identifier instead of kABPersonHomePageLabel, e.g.
ABMultiValueRef webpages = ABRecordCopyValue(person, kABPersonURLProperty);
// Then iterate thru webpages to get the homepage
for (CFIndex k=0; k < ABMultiValueGetCount(webpages); k++)
{
// Your code here
}

Resources