J2ME Exception types - java-me

I have read about MIDletStateChangeException. I wanna know other J2ME specific exceptions. Any ideas ?

Take a look at http://java.sun.com/javame/reference/apis/jsr118/. From there, I see:
CertificateException
ConnectionNotFoundException
InvalidRecordIDException
MIDletStateChangeException
RecordStoreException
RecordStoreFullException
RecordStoreNotFoundException
RecordStoreNotOpenException

Related

ANTLR4TS Java How to get Method Parameter types?

I need to get the parameters types of a method in a java file.
public static void main(String[] args) {
myMethod();
}
Like in this code I wanna to get just String[] without anything infront or behind it.
I use ANTLR4TS with the Java9Parser file distributed by them. Maybe somebody here knows how to do it?
Got it, its the enterFormalParameter.
enterFormalParameter (ctx: FormalParameterContext){
ctx.getChild(0).text;
}
Thats the way to get it.

Get cellular carrier's name from windows phone 10

I am currently developing UWP application that I need to get the celullar carrier's name. I saw posts about it for windows phone 8 and 8.1. They use:
DeviceNetworkInformation.CellularMobileOperator;
But it is depricated now.
Here is what I want for better clarification:
Does anyone knows how to make it work for windows phone 10?
All the help would be greatly appreciated. Thanks in advance.
We can use PhoneLine.NetworkName to get the name of the current network that is being used by the phone line.
To use the Windows.ApplicationModel.Calls namespace, we need add the reference like the following image:
The telephony options and information classes use the CallsPhoneContract. In order to use these classes, you will need to declare the phoneCall capability in your manifest like the following image.
For example:
private async void Button_Click(object sender, RoutedEventArgs e)
{
PhoneCallStore phoneCallStore = await PhoneCallManager.RequestStoreAsync();
Guid lineId = await phoneCallStore.GetDefaultLineAsync();
PhoneLine line = await PhoneLine.FromIdAsync(lineId);
var currentOperatorName = line.NetworkName;
}
An example that demonstrates how to use much of the functionality of the Windows.ApplicationModel.Calls API can be found here.
The UWP does not provide built-in api's for things like Mobile Network and Carrier related information, so MNC, MCC, carrier name etc are not possible to get afaik.
From the documentation thing might help you. I'm not sure, but it stands to reason that some of that information might be hidden there.
Microsoft documentation
Javascript:
var networkInformation = Windows.Networking.Connectivity.NetworkInformation;
C#
public static class NetworkInformation
C++
public ref class NetworkInformation abstract sealed
And you might need to go into one of the submethods provided by this class. Maybe getConnectionProfiles will do what you want

java.lang.VerifyError: me.xxx.menu.MenuListFragment only on Android 2.x.x

after almost 2 week trying to solve this strange problem, I give up!
Basically a get the java.lang.VerifyError every time I try to run my app
only in devices with Android 2.x.x. From 3.x.x all are going well.
In the project I'm using this two external library:
Action Bar Sherlock - http://actionbarsherlock.com/ - updated at the v4.4.0
Sliding Menu - https://github.com/jfeinstein10/SlidingMenu
This is what the LogCat return every time:
FATAL EXCEPTION: main
java.lang.VerifyError: me.xxx.menu.MenuListFragment
at me.xxx.menu.BaseSlidingMenuActivity.onCreate(BaseSlidingMenuActivity.java:46)
at me.xxx.menu.SlidingMenuCustomAnimation.onCreate(SlidingMenuCustomAnimation.java:28)
at me.xxx.XXXActivity.onCreate(XXXActivity.java:130)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
and this is how the BaseSlidingMenuActivity.java looks like around the line 46:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(mTitleRes);
// set the Behind View
setBehindContentView(R.layout.frame_content);
if (savedInstanceState == null) {
FragmentTransaction t = this.getSupportFragmentManager().beginTransaction();
mFrag = new MenuListFragment(); <--- ERROR HERE!
t.replace(R.id.frame_content, mFrag);
t.commit();
} else {
mFrag =(SherlockListFragment)this.getSupportFragmentManager()
.findFragmentById(R.id.frame_content);
}
...
...
}
Where MenuListFragment() is a SlidingFragmentActivity that extend a SherlockFragmentActivity
and implements SlidingActivityBase.
Of course I googled the problem, and seems that a lot of people are getting this
issue with the last version of the Android SDK tool, i.e. v22.x.x , in fact a have
the v22.6.3.
Some people resolved the VerifyError just putting the Check on the "Private Libraries"
box, inside "BuildPath->Configure BuildPath->Order and Export" menĂ¹, as explained
in other conversation about the VerifyError, but for me doesn't work, even because the "Private Libraries" was already checked. So the libraries/imports situation seems to be ok!
Hoping that someone already fund a solution for that! I'm getting crazy! :D
Thank you!
I finally found the solution!
Recap! Basically the are two main reason in which you can get this error:
(In my case) I was getting the VerifyError all the time that I tried to run my app on devices with API Level under 10 , because I was trying to catch an SQLiteDatabaseLockedException that are supported from the Android API Level 11. So to solve it check that every Exception or possible method (i.e. String.isEmpty() is supported from API Level 9) is supported form your minimum API Level.
While I was searching for a solution I found a lot of people that got the VerifyError because there was some problem with Libraries Imports, as explained in this post: http://commonsware.com/blog/2013/05/23/do-not-manually-modify-eclipse-build-path-except-now-r22.html
Hope that will help someone beyond me! :D
Bye Bye! Caterpillar.

Using javax.sound.sampled with openjdk-7 on Raspi

I'm having big problems getting good sound out of my Raspi using Java.
I want to write an little AirPlay Client to a media server I wrote in Java. I started with using the Player Class from javazoom (http://www.javazoom.net/javalayer/docs/docs1.0/javazoom/jl/player/package-summary.html). Which gave me a not really choppy but somehow distorted and slower than normal playback of an mp3 file I streamed over to the Raspi.
My first idea was, that maybe the decoding of an mp3 was a bit too much for the Raspi, especially since overclocking helped a little.
So now I'm converting the mp3 to a wav file on the server and then stream it to the Raspi playing it with the javax.sound.sampled.* stuff. Yet, no improvement :|
Has anybody some experience with playing soundFiles from Java on an Raspi? Any advice helps!
Thanks, Stefan
I suggest you try using JavaFX instead. It is way better than support for media on the standard JDK. Besides, you are already using Java 7, so migrating will be easy. Here is how:
Media media = new Media(Utils.findURI(baseDirName, soundFileName).toString());
SwingUtilities.invokeLater(new Runnable() {
#Override
public void run() {
Platform.runLater(new Runnable() {
#Override
public void run() {
MediaPlayer mediaPlayer = new MediaPlayer(media);
mediaPlayer.setCycleCount(1);
mediaPlayer.play();
}
});
}
});
the implementation of sound in OpenJDK has lots of bugs. One of them is that it abuses the sound system and monopolizes it. So on Linux you have better chances to get things working if you do as above.

Multiple Threads in Xpages

I have a problem and hoped somone could help me
I'm trying to start multiple threads from an XAgent (not rendered XPage)
public class ImportThread extends NotesThread {
Session currentSession;
public ImportThread(String maildb, String Server)
{
try{
currentSession =DominoAccess.getCurrentSession();
this.maildb = currentSession.getDatabase(Server, maildb);
}catch (Exception e) {
e.printStackTrace();
}
}
public void runNotes()
{
View v = maildb.getView("$Calendar");
}
in this version I could not access the View I only get "null" back
Ive tryed a version with Java Threads not realy better.
thean i've found something on Openntf
http://www.openntf.org/internal/home.nsf/project.xsp?action=openDocument&name=Threads%20and%20Jobs
but there I got an "AccessControl Exception"
I have no more ideas, I hope that someone has an idea how to create
an XAgent with multiple thread
As Egor wrote you need the change the Java policy file if you run the Java code from an NSF. You don't have to do this if you deploy your Java code as OSGi plugin. See the documentation of that OpenNTF project.
Afaik NotesObjects should not be shared between threads. So instead of using Database mailDB you should use String mailDBName and instantiate all NotesObjects inside their own thread. You also need to watch run time: if your XAgent waits for the treads to conclude, you should be fine, but if it is a 'fire-and-forget' approach you need to start it from something more persistent like a managed bean in the session scope.
Hope that helps

Resources