Tag Archives: android

Using ePubLib for Android

I’m rewriting the Examine the Scriptures Daily android app. With the ESD files published as ePub files it’s easier to get the data now, and it will allow more languages to be supported without the hassle of converting from WTLib.

Here’s the code snippet I’m using to read the ePub book. The library I’m using is ePubLib, and I’m displaying the page in a standard WebView:

    // Load the book and get a specific date
    AssetManager assetManager = getAssets();
    try {
		// find InputStream for book
		InputStream epubInputStream = assetManager.open("es12_E.epub");
		// Load Book from inputStream
		this.book = (new EpubReader()).readEpub(epubInputStream);
		getSpecificdate("2012-12-1");
	} catch (IOException e) {
		Log.e("epublib", e.getMessage());
	}

    private void getSpecificdate(String day) { 
		Date d; 
		int dayOfMonth;
		int monthOfYear;
		Calendar cal = Calendar.getInstance();
		try {
			d = dateFormat.parse(day);
			cal.setTime(d);
			String hrefDate = hrefFormat.format(d).toUpperCase();
			dayOfMonth=cal.get(Calendar.DAY_OF_MONTH);
			monthOfYear=cal.get(Calendar.MONTH);
			hrefDate += (dayOfMonth==1) ? ".xhtml" : "-split"+dayOfMonth+".xhtml";
			hrefDate = dblzero.format(monthOfYear+4)+hrefDate.substring(2);
			
            // Here's the part you're looking for
			Resource r = this.book.getResources().getByHref(hrefDate);
			WebView wv = (WebView) findViewById(R.id.webView1);
			String data = new String( r.getData() );
			wv.loadDataWithBaseURL("file:///android_asset/", data, "text/html", "utf-8", null);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		
	}

Similar Posts:

Tagged , , , , , ,

Android Plugin for Eclipse Hanging

For a couple of weeks now I have been trying to get the Android Plugin for Eclipse to play nicely on my new 64bit Ubuntu 11.10.
It was always hanging without a good explanation. The only message I got was “Loading Data for Android 2.3.3” and it reaches 100% but stays there.

I thought it was related to the fact that I’m using the latest Indigo (3.7) eclipse, but that wasn’t it (I tried with earlier versions). I also thought it was because of the 64bit java I installed separately (not using apt). That wasn’t it either (the apt installed version didn’t work either). Stupid solutions, I know, but I had to try!

The solution was to rename the SDK directory and remove the _x64 from the end of that. After that, I set it in Windows -> Preferences -> Android -> SDK location and applied the changes and voila! It works now.

I’ll be fixing the ESD app based on some kind feedback from friends. And maybe work on other pending projects as well. Stay tuned.

Similar Posts:

Tagged , , ,

Daily Scriptures Android App

I’ve been working on my M/WHM app for Android.

That was delayed because of a computer crash that brought me back a week or so on coding (thanks to github, everything is not lost). That gave me time to think through some design decisions, so I postponed going back to work on that for a little while.

Meanwhile, I wrote a daily scriptures reading app for android. The code is now on github at https://github.com/abdallah/Examine-the-Scriptures-Daily-for-Android. I will release it on the market in a few days when I test it some more.

[adsenseyu2]
A (mostly) working .APK is attached to this post. Feel free to contact me if you have any comments or requests.
The app is now in the android market. Use this link, or the QR code below. The apps.deeb.me page should have the latest news.
Examine Scriputres Daily - Android App

Similar Posts:

Tagged , , , , ,