I am working on application where I need to open inbuilt apps in a custom screen like in Popup window
but when I invoke the inbuilt app the screen size is full screen while I need customize screen size. The inbuilt app can be anything like browser or pdfreader.
Here is my code :-
String strurl = "/sdcard/download/28889.pdf";
File file = new File(strurl);
if (file.exists()) {
Uri path = Uri.fromFile(file);
// Log.e("path of the file",path.toString());
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
startActivity(intent);
}
catch (ActivityNotFoundException e) {
Toast.makeText(getApplicationContext(),
"No Application Available to View PDF",
Toast.LENGTH_SHORT).show();
}
This opens up new window in my app but I need Popup kind of window where I need to show this pdfreader to get display.
By design, Android does not allow one app to run inside another (among other things, for obvious security reasons). So if that is what you want to do, you are out of luck.
BUT you can use a WebView (I let you consult the doc on this class) to display a webpage inside your app.
There are also some pdf libraries out there. A word of caution though, I worked on a pdf reader on Android 1 year ago and implementing a pdf reader was just not the best solution. Handling the pdf decoding on server side and serving a view of this image (or conversion to html) was the best solution.
This way you don't use too much computing power to read the pdf (surprisingly you need some serious cpu to read a pdf).
Things may have changed since I made that development (I was really constrained by the time factor) though but I still don't think that unless you explicitely need to display a pdf document and not just a document (for example a legitimate reason would be that you need to check the signature of the pdf on the Android device), you should not use the pdf format on a phone.
For web URL You can use Webview
For PDF
You need to make your pdf reader or you can use any open source pdf reader to make your own customized version of the pdf reader which you can use in your app.
Some of the them are
1) http://www.mupdf.com/
2) http://sourceforge.net/projects/pdfedit/
3) Search on Google/SO for other Links
Here is the Example code for pdf Reader:
http://lokeshatandroid.blogspot.in/2012/07/android-pdf-reader.html
Related
I am loading an html page from a web server into a Xamarin Forms WebView. This html page contains links to a PDF file.
In iOS, when the user clicks the link, the PDF file is downloaded and opened.
In Android, when the user clicks the link, nothing happens. Note that several PDF-Viewers are installed on the Android device.
Is there any configuration necessary for make this work in Android:
Here is the code:
if (dict.ContainsKey("url")){
string url = dict["url"];
if (Uri.IsWellFormedUriString(url, UriKind.Absolute)){
NotifWebView.Source = url;
} else {
var htmlSource = new HtmlWebViewSource();
htmlSource.Html = #"<html><body><h1>Fehler!</h1><p>Ungültige oder keine URL oder ungültiges HTML.</p></body></html>";
NotifWebView.Source = htmlSource;
}
}
Thanks for your help!
You can use
https://github.com/xamarin/recipes/tree/master/Recipes/xamarin-forms/Controls/display-pdf
The WebView control can display PDF files on the iOS platform, but not on the Android and Windows Phone platforms due to lack of platform support.You need to create a custom renderer to acheve it in android platform.The process for doing this is as follows:
Create a Xamarin.Forms custom control
Consume the custom control from Xamarin.Forms.
Create the custom renderer for the control on each platform.
If you're willing to spend some money, it looks like Syncfusion has a solution for viewing and editing PDF files.
http://www.syncfusion.com/products/xamarin
I'm implementing some kind of magazine viewer (to browse pages like in android gallery), which content is taken from pdf file; pages must be zoomable. At first, I've tried to work with separate pictures from that pdf. I borrowed ImageViewTouch and ImageViewTouchViewPager. It works well, but I couldn't keep more than 3-4 big pics in memory (OutOfMemory error) , so that implementation is not suitable for me. (I need 5 big pictures in memory plus memory for about 50 little pictures to show table of contents)
So I've decided to work with pdf file. I've tried to display pdf with PdfViewer.jar, but this implementation with PDFViewerActivity is missing pictures or text when you try to zoom in or zoom out.
Can you advice me how to display my pdf like in android gallery? Or, at least, tell me, please, if you know views, which can display PDFPage with zooming option?
Edited: I do not need to open side app to view pdf. I need to dosplay it in my app.
You can give this a try:
public static void openPdf(Context context, String filename) {
File targetFile = new File(filename);
Uri targetUri = Uri.fromFile(targetFile);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(targetUri, "application/pdf");
try {
context.startActivity(intent);
} catch (ActivityNotFoundException act ) {
Toast.makeText(context, "Please install a pdf reader to view help",Toast.LENGTH_LONG).show();
}
}
I can load images from feed file into text box in normal flash as3 application,
but When I load same file into Air for Android it does't work.
here is the code please read and help me.
"This is Air application for Android in flash as3"
var txt:TextField = new TextField();
addChild(txt);
txt.htmlText="image url"
from the above code image is not loading.
but the same code works in normal flash as3.
have you tried to use StageWebView for displaying html content (like an image in your example)?
also if the html text didn't worked have you considered using Loader class
var img:Loader = new Loader();
img.load(new URLRequest("image url"));
addChild(img);
also the sample above doesn't include vital parts like IOError handling and other elements but this you can find on your own:)
best regards
Is there a way to download just the icons that are stored in a particular application from Google Play/Market without downloading the entire APK and installing it?
You can do this but it would require downloading he page source and then parsing it.
What you could do is first download the webpage, i like JSoup. Like
Document d = null;
try {
d = Jsoup.connect("https://play.google.com/store/apps/details?id=" + packageName).get();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Then you should parse that document for the following tag ""
Elements div = d.getElementsByAttributeValueContaining("class", "doc-banner-icon");
String path = div.get(0).attr("src");
This path variable should be the path for the image to download. I have not tested this.
Nope
There is no official API for market content. Be it to retrieve icons or anything else.
If you are just interested in getting the image files you can download them manually via the web front end to the Market. But I wouldn't write code to do this, as it is very likely that they will make a change to the web front end that will result in your code breaking. p.s. I am no lawyer, but also I don't think there is very much that you would be "allowed" to do with these images even if you did download them (without permission from each developer of course)
The answer by Jug6ernaut will no longer work. This works as of November 2016:
#WorkerThread public static String scrapeGooglePlayIcon(#NonNull String packageName) throws IOException {
return Jsoup.connect("https://play.google.com/store/apps/details?id=" + packageName).get()
.select("div[class=details-info] > div[class=cover-container] > img[class=cover-image]")
.attr("abs:src");
}
I created a small library that web scrapes the Google Play store. If this stops working in the future, please comment or create an issue on the GitHub project: https://github.com/jaredrummler/GooglePlayScraper
You could create a Yahoo Pipes like this http://kcy.me/hylg it will parse the page for you and extract a JSON in wich you could read the sinlge image URL.
http://kcy.me/hylj
You can parameterize the pipe in order to receive the link to the app you want to extract the image.
The simple solution is that just right click on the icon of the app from Chrom browser and save image as, this will save the icon with webp extension, now use this Conver webp to png
to convert the icon to PNG.
I am searching an ImageViewer library that opens an image in my application for a given URI (the image fetched by a webservice is already stored within my application in a secured place). I really like the "Samsung Galaxy S" ImageViewer-Activity because it uses pinch-zoom and "scrolling" vertical/horizontal. Also it scales the picture very fast on my samsung phone :)
I know that I can open an image with an intent like this:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(uri, "image/*");
startActivity(i);
The best suitable viewer is being called, when none is found an ActivityNotFoundException is raised. So thats cool!
But the problem is that I am not allowed to open an image with an external intent (for security purposes). i.e: The user should not have the posibility to save the opened image via a menu option to his external sd-card or send this picture to another service (email/twitter or s.o.). So I have to write my own ImageViewer-Class (Activity) that can only be called within my application...
Unfortunately I am not very skilled transforming images, so is there any open source project (or library) that covers this use case?
I already asked google and found this one http://code.google.com/p/android-pinch/ but it didnt work very well (also it has no scroll-functionality).
Thanks for your tips :)
At this moment I'm too use WebView. But this is conceptually wrong, WebView is not for displaying images, it for displaying web content. WebView is bulky and cumbersome. You restricted in customizing it. For example, I need scaling, but I don't want to see zoom controls, or I want to move them in other place then default.
Therefore, I searched about this problem and found some solutions:
PhotoView widget from Chris Banes
Also, you can look at this tutorial from Sony Ericsson (sources available) and can implement your own widget: part1, part2, part3
And another one library ImageViewZoom at github
UPDATE
Chris Banes was created awesome library which supports gestures for zooming pictures, see first point above
The easiest way to handle images is using a WebView, if the image is stored local or somewhere online. WebView supports pinch to zoom and other functions.
Example Java:
String imageUrl = "file:///local/dir/image.jpg"; // http://example.com/image.jpg
WebView wv = (WebView) findViewById(R.id.yourwebview);
wv.getSettings().setBuiltInZoomControls(true);
wv.loadUrl(imageUrl);
XML source:
<WebView android:id="#+id/yourwebview"
android:layout_width="match_parent"
android:layout_height="match_parent" />