Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

GenyMotion and PDF Reader

$
0
0

Im just full of questions it seems :-)

I am trying to open a PDF in Androind and having bit of trouble with Adobe Reader. I installed Adobe Reader in the Genymotion Simulator like so..

MacBook-Pro-2:~ david$ /Applications/android-sdk-macosx/platform-tools/adb install ~/Downloads/Adobe_Reader_9.0.2.apk
7011 KB/s (1839413 bytes in 0.256s)
    pkg: /data/local/tmp/Adobe_Reader_9.0.2.apk
Success
The app installs but when I try to open it with with my App or manually, it displays an error that say "Unfortunately Adobe Reader has stopped"

Here is my code (that I borrowed form this forum) where I am just trying to prove that the concept works.

//Check for an updated version of the PDF
    var file = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, 'trendpages.pdf');
    if (file.exists()) {
        htmlLocation = file.nativePath;
    }else{
 
        htmlLocation = Ti.Filesystem.resourcesDirectory + 'HTML/trendspages.pdf';
 
    }
 
    var appFilePath = htmlLocation;
    var appFile = Ti.Filesystem.getFile(appFilePath);
    var tmpFile = undefined,
    newPath = undefined;
 
    tmpFile = Ti.Filesystem.createTempFile();
    newPath = tmpFile.nativePath + '.pdf';
    tmpFile.move(newPath);
    tmpFile = Ti.Filesystem.getFile(newPath);
    tmpFile.write(appFile.read());
 
 
        alert("openpdf");
        var intent = Ti.Android.createIntent({
            action: Ti.Android.ACTION_VIEW,
            type: "application/pdf",
            data: tmpFile.nativePath
        });
 
        try {
            Ti.Android.currentActivity.startActivity(intent);
        } catch(e) {
            Ti.API.debug(e);
            alert('No PDF apps installed!');
        }
How do I get Adobe Reader to run properly so I can test my code? I'm trying to source a couple now but I dont have an Android device to test on at the moment, so I'm stuck with the simulator for now.

Thanks,

David


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>