If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Android™ Runtime Development

Reply
Contributor
asharma
Posts: 39
Registered: ‎02-18-2013
My Device: Developer
My Carrier: Don't Know
Accepted Solution

Unable to show downloaded file

HI,

 

I ported one android application. Which has functionality to download a file and store and then show it in device.

 

I am Unable to shoe the file.

 

The file is getting downloaded successfully. at location Z:\misc\android\attachments

 

When I debug the code I am getting path of downloaded file as /SDCARD/attachments/

 

I am using follwoing code to download file at path

 

String PATH = Environment.getExternalStorageDirectory()+ "/attachments/";

 

To show downloaded file I am using following code

Intent intent = new Intent();
			intent.setAction(Intent.ACTION_VIEW);
			Uri uri = Uri.fromFile(downloadedFile);
			
			//String mimeType = getMimeType(downloadedFile.getAbsolutePath());
			
			//if(extention.equalsIgnoreCase("pdf")){
			if(attachmentFileName.contains(".pdf")){
				
				try {
					intent.setDataAndType(uri, "application/pdf");
					intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
					startActivity(intent);
				} catch (Exception e) {
					// TODO Auto-generated catch block
					showAttachmentException();
					//e.printStackTrace();
					//showAttachmentException();
					
				}
			}

 

Please guide me on this.

 

Please use plain text.
BlackBerry Development Advisor (Retired)
jjasmann
Posts: 264
Registered: ‎01-08-2013
My Device: BlackBerry 10 Dev Alpha B
My Carrier: Bell

Re: Unable to show downloaded file

Hey asharma,

 

Could you elaborate on what you mean when you say you're unable to show the file?

 

Is there an exception, is the file not in the directory, is the Uri malformed, etc.?

 

    Justin

Justin Jasmann | Android Application Development Consultant
Developer Relations
developer.blackberry.com
Please use plain text.
Contributor
asharma
Posts: 39
Registered: ‎02-18-2013
My Device: Developer
My Carrier: Don't Know

Re: Unable to show downloaded file

Hi,

 

Unable to show PDF file means the PDF which I downloaded is not opening. I want that whenever i click on pdf link in my application it will start the PDF reader software and will open the downloaded PDF into that.

 

But this is not working on DEV Aplha device. but just now I teste dit on Z10 device it is opening.

 

 

Please use plain text.
BlackBerry Development Advisor
bbenninger
Posts: 130
Registered: ‎04-19-2013
My Device: BlackBerry Z10

Re: Unable to show downloaded file

I would upgrade the software on your dev alpha, perhaps it's quite old?
Please use plain text.