0

Hi I am writing the application to open HTML file.so for initial activity I am mentioning in AndroidManifest file as

 <data android:mimeType="text/html" />

In the activity I am getting the URI of HTML file by using following code.

 Uri mDataUri = = getIntent().getData();

and then by using following code I am reading the data of HTML file by using the following code

        ContentResolver cr = getContentResolver();
        InputStream input = cr.openInputStream(mDataUri);

from InputStream I am parsing the data and getting the content.

But now client want the Splash screen in the middle ,so if I read the data in SplashScrren I am unable to send to the SecondScreen because that file Content is more(after converting to string length is:3,00,000).

Now Same HTML How can I read in Second Screen ?

Lain
  • 2,166
  • 4
  • 23
  • 47
ashok reddy
  • 419
  • 1
  • 7
  • 14

2 Answers2

0

You do not need to declare the file in the AndroidManifest.xml. If you place your HTML file in the asset folder of your project you will able to use the AssetManager provided from the Application class in any activity:

AssetManager assetMgr = getApplication().getAssets();

You are able to get the same value for input by getting the InputStream:

InputStream input = assetMgr.open("nameOfFile.html");

If you are putting the content in a WebView you can just load file by name:

WebView webView = new Webview(context);

webView.loadUrl("file:///android_asset/nameOfFile.html");

Jon
  • 1,820
  • 2
  • 19
  • 43
  • the attachment file is not static.attachment i have to read from Email . – ashok reddy Dec 12 '12 at 07:05
  • On second thought, I think this is still the best way to go, you just need to write out the HTML file out to the device (assets folder or otherwise). The string is too big to fit into an `Intent` and takes up a huge chunk of space so long as it exists in RAM. I just found this link that seems to agree with some kind of solution like this: http://stackoverflow.com/questions/12496700/maximum-length-of-intent-putextra-method-force-close – Jon Dec 12 '12 at 14:37
  • BTW, I have been assuming you are unable to pass along that same URI to the next activity in an `Intent`, is that an option for you? Does only your first activity have access to the raw file for some reason? – Jon Dec 12 '12 at 14:40
  • yes..for first activity i am mentioning so i can get the data by using Uri mDataUri = = getIntent().getData();..but this will not available for secondactivity – ashok reddy Dec 12 '12 at 14:49
0

When we are putting the MimeTypes as text/html for an activity,you can read the data in That activity only,you cannot read from Another activity,so you can store locally and access in Second Activity.

user2020680
  • 131
  • 9