Delphi - android - raw data

I am integrating a third party Bluetooth printer into my Delphi XE7 Android app. For this they have provided the Jar file, license file and the manual. I used the JAVA2OP tool to generated the Delphi native bridge file from the java library. In the manual they mentioned that the License file is required to be added in the raw folder of your application project. How we do this in the Delphi? what I done is in the Project->Deployment added this file and given the remote path as 'res\raw'. is it correct? Sec
ondly they are mentioning create an object of the class 'setup', I did it and working correctly. In the setup class there is one method named ActivateLibrary to activate all the libraries in the SDK. The syntax of this function is

Boolean blActivateLibrary(Context Jcontext, int iRawFileID) 
where Context should be the Application/global information about an application environment and iRaFileID is the configuration(license) file required for activate the library.

The Java example they provided is:
SetUp1 = new Setup();
boolean activate1 = SetUp1.ActivateLibrary(context,R.raw.licence);
if (activate == true) 
{
    Log("Library Activated.");
} else if (activate == false) {
    Log("Library Not Activated.");
}

What I did in Delphi for the same is:

Location := SharedActivityContext.getResources().getIdentifier(stringtojstring('licence'), stringtojstring('raw') , stringtojstring('com.embarcadero.PrinterTest'));
setup1 := TJsetup.Create;
if setup1 <>  nil then
begin
activate :=  setup1.blActivateLibrary(SharedActivityContext.getApplicationContext,Location) ;
if activate then
    showmessage('Library activated')
else
    showmessage('Library not activated');
end;

However, I am always getting the return value false. Is there anything wrong in it? I am not getting any support from the provider as they are not aware about Delphi.
0
Pramod
8/11/2015 2:39:42 AM
embarcadero.delphi.firemonkey 4901 articles. 2 followers. Follow

7 Replies
564 Views

Similar Articles

[PageSpeed] 33

Pramod wrote:

> what I done is in the Project->Deployment added this file and given
> the remote path as 'res\raw'. is it correct?

That, I cannot answer.

> Location := SharedActivityContext.getResources().getIdentifier(stringtojstring('licence'), 
stringtojstring('raw') , stringtojstring('com.embarcadero.PrinterTest'));

Did you verify that Location is not 0?  You could also try this:

{code}
Location := SharedActivityContext.getResources().getIdentifier(stringtojstring('com.embarcadero.PrinterTest:raw/licence'), 
nil, nil);
{code}

> activate := setup1.blActivateLibrary(SharedActivityContext.getApplicationContext, 
Location) ;

Have you tried using SharedActivityContext itself instead of getApplicationContext()?

{code}
activate := setup1.blActivateLibrary(SharedActivityContext, Location);
{code}

> However, I am always getting the return value false. Is there anything wrong in it?
> I am not getting any support from the provider as they are not aware about Delphi.

Any chance that the library is outputting some error information to Android's logcat to explain why it is failing?  Does the library provide any API to retrieve error information directly?

-- 
Remy Lebeau (TeamB)
0
Remy
8/11/2015 4:30:27 AM
Hello,

have you already run monitor.bat from you Android SDK's installation to
view the log messages during your program run? M;aybe they reveal something?

(I'd suspect a wrong path for the licence file)

Greetings

Markus
0
Markus
8/11/2015 9:33:13 PM
> Did you verify that Location is not 0? You could also try this:
yes the location is greater than zer, i tried the one you suggested and working 
> Have you tried using SharedActivityContext itself instead of getApplicationContext()?
yes getting the same result - False
> Any chance that the library is outputting some error information to Android's logcat to explain why it is failing? 
> have you already run monitor.bat 
I made below changes in the code and received the below log in the monotor.bat. Here it is showing the setup is the issue but i am getting a value greater than zero for the object when debug. Please advise

  setup1 := nil;
  log.d('Finding the Raw file id of the license');
  Loca :=  SharedActivityContext.getResources().getIdentifier(stringtojstring('licence'), stringtojstring('raw') , stringtojstring('com.embarcadero.PrinterTest2'));
  log.d('Initiliazing the setup');
  setup1 := TJsetup.Create;

  if setup1 <>  nil then
  begin
     log.d('activating the library');
     activate :=  setup1.blActivateLibrary(SharedActivityContext,Loca) ;
     if activate then
     begin
        log.d('Library activated');
        showmessage('Library activated');
     end
     else
     begin
        log.d('Library not activated');
        showmessage('Library not activated');
     end;
  end;


08-13 09:54:35.602: I/info(23870): FMX: PrinterTest2: Finding the Raw file id of the license
08-13 09:54:35.613: I/info(23870): FMX: PrinterTest2: Initiliazing the setup
*08-13 09:54:35.613: W/dalvikvm(23870): dvmFindClassByName rejecting 'com/prowesspride/api/Setup'*
08-13 09:54:35.623: I/info(23870): FMX: PrinterTest2: activating the library
08-13 09:54:35.623: I/info(23870): FMX: PrinterTest2: Library not activated
8-13 09:54:35.623: W/dalvikvm(23870): dvmFindClassByName rejecting 'com/embarcadero/firemonkey/dialogs/FMXDialogFactory'
08-13 09:54:35.623: W/dalvikvm(23870): dvmFindClassByName rejecting 'com/embarcadero/firemonkey/dialogs/FMXStandardDialog'
08-13 09:54:35.703: D/dalvikvm(23870): GC_FOR_ALLOC freed 170K, 11% free 8281K/9204K, paused 15ms, total 15ms
08-13 09:54:35.713: D/KeyguardUpdateMonitor(1434): sendKeyguardVisibilityChanged(true)
08-13 09:54:35.713: I/KeyguardUpdateMonitor(1434): visibility is same




> {quote:title=Markus Humm wrote:}{quote}
> Hello,
> 
> have you already run monitor.bat from you Android SDK's installation to
> view the log messages during your program run? M;aybe they reveal something?
> 
> (I'd suspect a wrong path for the licence file)
> 
> Greetings
> 
> Markus
0
Pramod
8/13/2015 5:09:26 AM
Pramod wrote:

> Please advise

Contact the API vendor and ask if they can provide you with a JAR that outputs 
diagnostic messages during activation, or throws an exception with error 
details, or something.  As it current stands, there is clearly a problem 
inside their API and nothing is telling you what is going wrong with it.

The only other possibility I can think of right now is if your project has 
a different raw resource named "license" that getIdentifier() is returning 
the ID of, and blActivateLibrary() is failing because it is not finding its 
expected license file.

-- 
Remy Lebeau (TeamB)
0
Remy
8/13/2015 6:28:25 AM
> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> The only other possibility I can think of right now is if your project has 
> a different raw resource named "license" that getIdentifier() is returning 
> the ID of, and blActivateLibrary() is failing because it is not finding its 
> expected license file.

Have you tried having your app open the resource data at runtime using the ID from getIdentifier(), and make sure it really is the same license file that you added to the Deployment Manager?

--
Remy Lebeau (TeamB)
0
Remy
8/13/2015 6:32:16 AM
> Have you tried having your app open the resource data at runtime using the ID from getIdentifier(), and make sure it really is the same license file that you added to the Deployment Manager?
I havent tried to open it but when I removed the license file from deployment manager then the getIdentifier returning zero that means it is working?
Also how can convert jstream to stream?

inputstream : JInputStream

inputStream = SharedActivityContext.getResources().getIdentifier(Loca);

> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> > {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> > The only other possibility I can think of right now is if your project has 
> > a different raw resource named "license" that getIdentifier() is returning 
> > the ID of, and blActivateLibrary() is failing because it is not finding its 
> > expected license file.
> 
> Have you tried having your app open the resource data at runtime using the ID from getIdentifier(), and make sure it really is the same license file that you added to the Deployment Manager?
> 
> --
> Remy Lebeau (TeamB)
0
Pramod
8/13/2015 9:43:00 AM
Pramod wrote:

> I havent tried to open it but when I removed the license file from
> deployment manager then the getIdentifier returning zero that means it
> is working?

I suppose so.

> Also how can convert jstream to stream?
> 
> inputstream : JInputStream
> 
> inputStream = SharedActivityContext.getResources().getIdentifier(Loca);

There is only one getIdentifier() method, and it does not return a stream, 
only an ID.  To get the actual data of a resource from its ID, use openRawResource() 
instead, which returns a JInputStream:

{code}
Loca := SharedActivityContext.getResources.getIdentifier(StringToJString('licence'), 
StringToJString('raw'), StringToJString('com.embarcadero.PrinterTest2'));
// alternatively, don't hard-code the app's package name, ask Android for 
it instead:
// ...getIdentifier(..., SharedActivityContext.getApplicationInfo.className);

if Loca > 0 then
begin
  inputStream := SharedActivityContext.getResources.openRawResource(Loca);
  // use inputStream as needed...
end;
{code}

You can use the JInputStream.read() methods to read the raw bytes of the 
resource.

-- 
Remy Lebeau (TeamB)
0
Remy
8/13/2015 5:23:20 PM
Reply:

Similar Artilces:

Delphi and Delphi for .Net
It seems that Delphi for .Net is slower than Delphi Win32 native applicaiton. I would like to know is it true all .Net application is slower than Win32 native applicaiton or it is Delphi for .Net only. Your information is great appreciated, Inung On 2011-06-21 18:20:17 +0100, Inung Huang said: > It seems that Delphi for .Net is slower than Delphi Win32 native applicaiton. > I would like to know is it true all .Net application is slower than > Win32 native applicaiton or it is Delphi for .Net only. If you are only running the code in the application once then, yes, yo...

Re: Where is data form wizard in Delphi 2009? [pubic.delphi.ide]
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --JivePart=_21560.zeB8CwDOH5aMJzMl Content-Type: text/plain; charset="Utf-8" Sample picture showing drag and drop from persistent fields edit window. (Any TField in any TDataset should work, TSomeKindofTable, or TSomeKindofQuery. Warren --JivePart=_21560.zeB8CwDOH5aMJzMl Content-Type: image/jpeg; name="drag_and_drop_from_persistent_fields_editor.jpg" Content-Transfer-Encoding: base64 Content-Disposition: attachment; ...

SEPA components for Delphi with Source Code (Delphi 5
Hi all, in the european union change next year the Bankingformat to the SEPA Format. All peoples and companies must change the bankingssoftware and the costumer data form acountnummers in the new IBAN and BIC numbers. See: http://www.arma-it.de/shop/artikelueber.php?wgruppeid=211&wgruppe_offen=211 Functions: - generate SEPA XML'S - Calc IBAN - BIC Database (DE,AT and CH) Questions: vertrieb@arma-it.de PS: Bankinssoftware for Develpoers (Germany only) http://www.arma-it.de/shop/artikelueber.php?wgruppeid=212&wgruppe_offen=212 El 26/10/13 21:38, A...

Delphi 7 to Delphi XE
Have been using Delphi 7 for many moons ( have got later versions but never upgraded to ) My first problem is: Component Palette. in XE it is a small toolbar docked in top right in Delphi 7 it gives a large view of all the components. I am struggling to be able to cope/access my components.in Delphi XE. Can I make the component pallette tool bar the same size as Delphi 7, or is there a fast way to view/choose all available components in XE, that I have not spotted yet? Kind Regards, Robert. Hi, What I know is that in Delphi 2010 and XE you can choose between t...

Delphi 5 to Delphi 6 and up
Dear List, Trying to add 7Zip compression support to my delphi application. I am using the ported 7Zip sdk (see their website, they have a link). I am stumped on how to rewrite a single function: function ReverseDecode(var Models: array of SmallInt; ....): ..... where the input is mostly a fixed size array of SmallInt. This code perfectly compiles and functions in Delphi 6 and up, but in Delphi 5 I get the error: There is no overloaded version of 'ReverseDecode' that can be called with these arguments And obviously, the input (fixed) isn't the same as the param de...

Delphi 2007 to Delphi 7
I've written a class in Delphi 2007 that is not supported in Delphi 7. What would be the best way to achive what I've done in Delphi 2007 in Delphi 7? Thanks, Tom type BondConstants = class { Bond Types } type BondType = record const TREASURY = 3; AGENCY = 0; CORP = 1; MUNI = 2; SBA = 5; MBS = 4; CMO = 6; end; { Day Count Methods } type DayCount = record const ACTUAL_360 = 2; ACTUAL_365 = 1; ACTUAL_ACTUAL = 1; d30_360 = 0; ...

Delphi 4 to Delphi 2007
Hello, I will have to port a D4 application (with source) to D2007. what kind of problem could I face ? I will have to go to customer site tommorow to analyse its source code to quote the work, what should I care of to hestimate the porting time ? Thanks John Terry wrote: > Hello, > I will have to port a D4 application (with source) to D2007. > what kind of problem could I face ? > I will have to go to customer site tommorow to analyse its source code > to quote the work, what should I care of to hestimate the porting time ? You can probably do it by just changi...

Delphi for PHP or Delphi PRISM
Hi, I have the opportunity to develop a web-based library management system. Nothing fancy, just being able to do the usual CRUD stuff for books and provide a search facility. Borrowing is to be done via an email request to the library admin who then sends out the book(s). Since both Delphi for PHP and Delphi PRISM will enable me to develop the app, which one will allow me to deliver it in less time and also increase (even how small) my marketability as a web developer? Thanks. Phillip Flores Phillip Flores wrote: > Hi, > > I have the opportunity to develop a...

Delphi 4 to Delphi 2009
Hello, Thanks to all who answered my previous question. That was a great help. And atlast our client agreed to upgrade our delphi version from 4 to Delphi 2009. *Sigh*. But before that, I need to give the estimation and cost regarding the migration to delphi 2009. Can anyone tell me is there any tool to migrate from delphi 4 to delphi 2009 or just I need to compile our Delphi 4 application in Delphi 2009. I have read from the delphi 2009 feature matrix that Delphi 1 through Delphi 2007 import is possible in delphi 2009. But i am not that sure considering the size of our application. ...

Delphi 5 to Delphi XE4
Thinking about making the conversion. Of course we have numerous components such as: TurboPower AsyncPro, TurboPower Orpheus ICS2 Synactis All-In-The-Box. You guys have any advice as to the effort and time it may possibly take. It is a large application, several hundred thousand lines. And that's what happens when using third party components, a lot of extra work. I have been burned a few times. I now minimize the use to a few well known suppliers, like TMS. I have "banned" a lot of other components. Regards, Ole > > Thinking about making the conver...

Delphi 5 To Delphi 2009
I upgraded to Delphi 2009 from D5. The install says I can install Delphi and/or C++. Delphi installed OK but I see nothing of C++. What am I missing or does my upgrade not include C++? Thanks It depends on what you bought. If you bought Delphi 2009 only, that's what you get. If you bought Delphi 2009 and C++ Builder 2009 you get both. My guess is you got Delphi 2009 only. The simplest way to verify is look your invoice - it should say I would think. You could also go to members.embarcadero.com, login, then click on my registered products. There will be a textual description of...

Delphi and virus, or virus and Delphi.
Hi all. There is some discussion about a 'new' virus, that targets Delphi (and developers). The article is in danish: <http://www.version2.dk/artikel/11833-delphi-udviklere-jages-af-ny-type-malware> but refers to this article: <http://news.cnet.com/8301-27080_3-10312628-245.html> From the Danish article POV, it seems like Delphi itself is vunerable, which is not true. As far as i can see, is the attack vector, injection of (source) code in the 'Sysconst' unit. What's going on? -- Best regards Stig Johansen Perhaps checking other thre...

Delphi 7 to Delphi XE2
Hi, Still using that old workhorse, Delphi7, but am going to the conference in London hosted by Embarcadero on Delphi XE2. Although I would like to "move with the times" and am keen to get the UNICODE and 64-bit support offered by the latest IDEs, I confess to being more than a little scared about all the UNICODE/String/AnsiString and 32/64 bit issues I'm probably going to fall over. Anyone recently upgraded from Delphi7 to one of the latest Delphi IDEs? Thanks, Alain On 03/02/2012 08:55, Alain Dekker wrote: > Still using that old workhorse, Delphi7, but...

from delphi 6 to delphi 2010
Hi. It is possible, with component RX, dxforumlibrary, InfoPower3000Pro, StringAlignGrid. Accepts communication BDE. Thank by comments. excequiel arostica wrote: >Hi. > It is possible, with component RX, dxforumlibrary, >InfoPower3000Pro, StringAlignGrid. Accepts communication BDE. > >Thank by comments. Rx is dead and sources are taken over by jcl/jvcl. I dont know about the rest of the components and i have no experiences with bde over the last 9 years. excequiel arostica wrote: > Hi. > It is possible, with component RX, dxforumlibrary,...

Delphi XE / Delphi 2010
Hello! I noticed that Embarcadero® Delphi® 2010 Version is not on the list of products on Embarcadero page. Or is it still possible to buy it? Will RAD Studio XE compile programs written in Delphi 2010 without problems.? Thanks. Am 13.09.2010 09:04, schrieb Petra Nemec: > Will RAD Studio XE compile programs written in Delphi 2010 without problems.? As always you will probably have to recreate the projects as the import is still a bit -- special. Christian Hello! Does anybody know if it is still possible to get a Delphi2010 trial version (if yes where)? ...

Web resources about - Delphi - android - raw data - embarcadero.delphi.firemonkey

Android Apps - Appolicious ™ App Directory
... You'll Love in association with Trending: games photography photo editing keyboards Join Sign In with Yahoo! Already a member? Log in Android ...

Android phone name generator
Just click on the logo. ∞ Read this on The Loop

Android version history - Wikipedia, the free encyclopedia
Global Android version distribution since December 2009. As of January 2014, Android 4.x Jelly Bean is the most widely used Android version, ...

SelfieMark Launches Photo-Sharing, Polling App on iOS. Android
SelfieMark has announced the release of its photo-sharing app on iOS and Android, which allows users to poll their peers in side-by-side image ...

6 changes we want to see in Android Wear - Android Authority
... part of our lifestyle, the battle is on for supremacy amongst the platforms that power the devices that adorn our wrists. Google’s Android Wear ...

Android app helps Iranians avoid morality police checkpoints
... helps people avoid being pulled from their car by the Ershad—Iran's morals police. Anonymous developers in Iran recently released an Android ...

This year’s best Android phones still might not be as fast as last year’s iPhone 6s
... a smartphone, and newly discovered performance test results suggest that the brand new Snapdragon chip set to power this year's flagship Android ...

How I use Android: 'All About Android' host Jason Howell
... Howell, right? You must know Jason Howell. Everyone knows Jason Howell. Okay maybe not everyone . But when it comes to people in the Android ...

Android creator will offer free dashcams in exchange for drive data
Andy Rubin, who co-founded Android before leaving Google in 2014, is building dashboard cameras that he wants to give away for free. But in exchange ...

Instagram Adds Support For Switching Accounts On iOS, Android App
... be able to switch between multiple accounts without hassle. Instagram announced on Monday that users of its official app for both iOS and Android ...

Resources last updated: 2/11/2016 8:29:26 AM