IntlPrefix v1.0.7 was released. This version adds Spanish, French and Japanese language translation. Also, it adds support for HTC Sensation on Android 2.3.3 (HTC phones require special handling).
As usual, you can install this version directly from the Market application on your Android phone, and you can download the source code from Google Code.
Thursday, September 1, 2011
Sunday, August 14, 2011
Android outgoing call interception
An android App can alter outgoing calls by creating a
What I have done in IntlPrefix to workaround this issue is to cancel the current call, and then make a new one. Below is the new code:
Hope this information is useful for other Android developers out there.
BroadcastReceiver to intercept the ACTION_NEW_OUTGOING_CALL intent and set the resultData to the new number to be called (or null in order to cancel the call). Some example code:public class CallReceiver extends BroadcastReceiver
{
public void onReceive(Context context, Intent intent)
{
String dialedNumber = intent.getStringExtra(
Intent.EXTRA_PHONE_NUMBER);
// do some useful conversion on the dialed number
String correctedNumber = correctNumber(dialedNumber);
setResultData(correctedNumber);
}
}Unfortunately, some handsets seem to completely ignore the new phone number passed to setResultData so software relying on this function does not work.What I have done in IntlPrefix to workaround this issue is to cancel the current call, and then make a new one. Below is the new code:
public class CallReceiver extends BroadcastReceiver
{
public void onReceive(Context context, Intent intent)
{
String dialedNumber = intent.getStringExtra(
Intent.EXTRA_PHONE_NUMBER);
String correctedNumber = correctNumber(dialedNumber);
if(useAlternateMethod())
{
// Cancel current call and make a new one on (buggy)
// phones that ignore call to setResultData
setResultData(null);
Intent callIntent = new Intent(Intent.ACTION_CALL,
Uri.parse("tel:" + correctedNumber));
callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(callIntent);
}
else
{
// All other models: just setResultData to the new
// phone number
setResultData(correctedNumber);
}
}
useAlternateMethod returns true on "broken" phone models, indicating the workaround must be used (I keep adding models as my users report IntlPrefix does not work on their phones): private boolean useAlternateMethod()
{
String product = android.os.Build.PRODUCT;
int sdk_int = android.os.Build.VERSION.SDK_INT;
return
// HTC Desire on Android 2.2
(product.equals("htc_bravo") && sdk_int == 8)
// HTC Desire S on Android 2.3.3
|| (product.equals("htc_saga") && sdk_int == 10)
// HTC Wildfire S on Android 2.3.3
|| (product.equals("htc_marvel") && sdk_int == 10)
;
}
}
Note that due to this alternate method, your App will now need the CALL_PHONE permission. But well, that's life.Hope this information is useful for other Android developers out there.
Tuesday, August 9, 2011
IntlPrefix 1.0.6 released
Yesterday, IntlPrefix v1.0.6 was released. This version adds support for HTC Desire S on Android 2.3.3 and HTC Wildfire S on Android 2.3.3 (HTC phones require special handling).
You can install this version directly from the Market application on your Android phone, and you can download the source code from Google Code.
You can install this version directly from the Market application on your Android phone, and you can download the source code from Google Code.
Sunday, August 7, 2011
Matching Kanji to readings
I'm writing a piece of Java code to automagically match Kanji to readings, generating text similar to Japanese studying textbooks, where the yomigana is displayed on top of the corresponding Kanji.
The code I wrote uses the reading list from Kanjidic2 to find the best possible Kanji / yomigana combination. Since not all possible Kanji readings are listed, the software applies several conversions (such as Dakuten, Handakuten, irregular Okurigana, etc...).
After this reaches some level of maturity, I'd like to share it as a Java library so it can be used by other software. Below is a Demo applet (note: Java 1.6 or better required). Do not hesitate to post a comment if there are any strange conversions, so that I can use this information to improve the algorithm.
The code I wrote uses the reading list from Kanjidic2 to find the best possible Kanji / yomigana combination. Since not all possible Kanji readings are listed, the software applies several conversions (such as Dakuten, Handakuten, irregular Okurigana, etc...).
After this reaches some level of maturity, I'd like to share it as a Java library so it can be used by other software. Below is a Demo applet (note: Java 1.6 or better required). Do not hesitate to post a comment if there are any strange conversions, so that I can use this information to improve the algorithm.
Subscribe to:
Posts (Atom)