Categoryphones

Fixing T-Mobile international roaming

T-mobile has awesome phone plans for people living in America to get free international roaming in over 140 countries. For most people, all they’d have to do is flip the switch on their phones that enable international roaming. For a minority of people, there are a few more settings to mess with. In the past year, I’ve had two issues that resulted in me losing my data connection outside of USA and I’m documenting some things below to try since it worked for me – maybe it’ll help some people out.

Check that international data roaming is enabled

Try a different APN

I’m using “T-Mobile US LTE 260”. Not sure if changing this requires a phone restart. I restarted my phone anyway.

Set the APN protocol and APN roaming protocol to IPv4/IPv6

Just tap on the APN you want to change. Hitting the 3 dots will show the save button. Not sure if changing this requires a phone restart. I restarted my phone anyway.

An App for Periodically Vibrating A Phone with Java Micro Edition

March 12, 2011 – An App for Periodically Vibrating A Phone with Java Micro Edition

Nowadays, people probably program for Android or iOS, but I don’t have a high-tech phone that runs Android or iOS or anything. I needed an app that would make my phone vibrate every few minutes. I often find myself falling into a food coma, so I’m hoping that a phone that vibrates periodically will help keep me awake. I figured this would be a good learning opportunity for me, so I didn’t bother looking very hard to see if an app for this already exists. I went through setting up my development environment, coding the MIDlet (what they call Java apps on phones) using the J2ME libraries, testing using the emulator and packaging the app for deployment. My code is also available for download.

Setting Up the Development Environment

To develop this app, I used Eclipse combined with a plugin called EclipseME. To test the app, I used the Sun Java Wireless Toolkit for CLDC. Also, in order to program anything in Java, one must also have the JDK.

Required Programs

Download and install the programs below to set up the development environment. There are quite a few things to install here, but most of it is just download and double-click, except for the stuff that has to do with EclipseME.

  1. JDK
  2. The JDK can downloaded here

  3. Eclipse IDE
  4. Eclipse is a free IDE for different programming languages such as Java, C++ and PHP. It can be downloaded here

  5. Sun Java Wireless Toolkit
  6. This program provides all the tools for debugging the program such as the phone emulator and also allows the programmer to package the app into a usable jar file for the phone. At the time of this writing, the version for this program is 2.5.2_01. The program can be downloaded here

  7. EclipseME
  8. This is a plugin for Eclipse that adds functionality for programming apps for mobile phones. For example, it allows the programmer to code, debug, and deploy with one piece of software rather than coding elsewhere and compiling with the Wireless Toolkit. The method to install it is to use the update manager within Eclipse. Detailed instructions here

    After installation, I had to configure the virtual devices the program would use for debugging. Initially, there are no devices listed in the preferences and when I went to create a new Eclipse project, picking a device was required. The link below has instructions how to do this configuration. However, I made one slight change to it, which is the search directory. The Wireless Toolkit installed itself in “C:WTK2.5.2_01” rather than “C:Softwaretoolkitswtk22”.

    Follow the link here for instructions how to set up the virtual devices.

Once all this is done, the actual programming can begin. The next thing to do is to create a new project.

Creating A New Project

To create a new project:

  1. Go to File > New > Project (not Java Project)
  2. Expand the heading J2ME
  3. Choose J2ME MIDlet Suite
  4. Click Next
  5. Type in a name and choose the directory that it will go in
  6. Choose the Sun Java Wireless Toolkit at where it says Group, in the Devices section
  7. Choose a device under where it says Device, but it doesn’t matter which one is picked unless the phone app depends on the different phone interface
  8. This is where the device management step came in. Hopefully, the configuration was done earlier. If not, click here for instructions.

  9. Click Finish

The project is now created and we are not ready to begin writing code. But as an aside, below is a brief explanation of what MIDlets are.

What Is A MIDlet?

In short, a MIDlet is basically the app that runs on the phone. So when I’m talking about writing an app, I’m also talking about writing a MIDlet. The word app just sounds less technical.

All Java MIDlets use a class that extends the MIDlet class. So I made a class called WakeUpMIDlet that extended the MIDlet class. Also, the extended class, must define/override some of the methods that exist in the super class (MIDlet). These methods are:

  • startApp()
  • destroyApp()
  • pauseApp()

These methods assist the MIDlet in transitioning to one of its three states, which are active, paused, and destroyed. The startApp method brings the MIDlet to the active state, while destroyApp takes the MIDlet to the destroyed state, and the pauseApp method will take the MIDlet to the paused state. When the MIDlet is created, the constructor for the class and startApp are called respectively. Click here for more information about MIDlets and J2ME in general.

Building the MIDlet

Here is where the actual coding for the vibrator app begins. I am also assuming that anybody reading this already knows the basics of programming Java. I will discuss the code I used to develop the MIDlet, but for those interested in the MIDlet equivalent of a “Hello World” program, click here.

About the App

Since I don’t want to slip into a food coma, I made this app to make the phone vibrate in regular intervals. These intervals can be set by the user. In terms of the GUI, there will be a text field for the user to input the interval time, and text to show the time until the next vibration. See the picture at the top of the post to see what the app will look like.

Imports

I used these imports in my program:

import java.util.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

The first import is so that I can use the timer object in the program, which is for doing the countdown. The second is to be able to extend the MIDlet class since we must subclass it (see the section “What Is A MIDlet” for more information). The third import contains the GUI functionality for the MIDlets, which includes the text fields, buttons, etc.

Extending the MIDlet Class

In addition to extending the MIDlet class, the CommandListener interface must be implemented as well in order for buttons to work.

public class WakeUpMIDlet extends MIDlet implements CommandListener

The code could have been inferred from the description, but I put it up for completeness.

Class Variables and Constants

Below are the variables and constants that I defined in my class. What the variables are for is in the comments but a more detailed explanation will follow.

private static final int DEFAULT_INTERVAL = 5;
private static final int VIBRATE_DURATION = 800;

Form GUI = null;
Command cmdStart = null;
Command cmdExit = null;

TextField tfVibrateInterval = null;
StringItem strTimeToNext = null;
StringItem strTime = null;
Timer timer = null;
TimerTask timerTask = null;

int count = 0;

The first two constants are just there for me to control what the default value for the vibration interval should be and how many milliseconds to vibrate for. The rest are all GUI elements and the objects/variables for managing the countdown.

Classes

Form – acts as a container for all the GUI elements such as the buttons and text fields. Later on, I will add each GUI element to this object of the Form class.

Command – used for buttons that appear at the bottom of the window.

TextField – GUI element for the screen that displays text and has a box for users to type in

StringItem – GUI element for displaying text in the Form

Timer – provides a way to run code at fixed intervals

TimerTask – defines what code the timer will run

With these objects set to null, we can now define them in the constructor. For more information about the classes involved in building the GUI, click here or see the references for more information.

The Constructor

I use the constructor to create all the GUI elements I need and to set up the form

public WakeUpMIDlet()
{
GUI = new Form("Wake Up!");
cmdStart = new Command("Start", Command.OK, 0);
cmdExit = new Command("Exit", Command.EXIT, 0);
timer = new Timer();
timerTask = new TimerCountdown();

GUI.addCommand(cmdStart);
GUI.addCommand(cmdExit);
GUI.setCommandListener(this);

tfVibrateInterval = new TextField("Vibrate Interval (min): ", String.valueOf(DEFAULT_INTERVAL), 5, TextField.NUMERIC);
tfVibrateInterval.setLayout(Item.LAYOUT_CENTER);
strTimeToNext = new StringItem("Time Until Next Vibration ", null);
strTimeToNext.setLayout(Item.LAYOUT_CENTER);
strTime = new StringItem("n0:00", null);
strTime.setLayout(Item.LAYOUT_CENTER);
strTime.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_LARGE));

GUI.append(tfVibrateInterval);
GUI.append(strTimeToNext);
GUI.append(strTime);
}

The constructor for the Form class takes one parameter, which is the name. This name gets displayed on the phone when the app is open on some phones.

The constructor for the Command class is the label that appears on the button, and what the purpose of the button is. There are a list of constants that go with this. Refer to the reference on the Command class for more information. The 0 at the end represents the priority of the button. The documentation has a really good explanation on what the priority represents.

The Timer and TimerTask objects are very straightforward as they don’t require any parameters in the constructor. However, the TimerTask object gets an object of its subclass. Subclassing the TimerTask class is required because that is where we put the code that runs at every timer interval.

The addCommand method adds the buttons to the form. In order to get button press events, we need to add a CommandListener (which is why we implemented the interface in the first place).

The next few lines are for defining what kind of text to display on the screen. The parameters there are quite straight forward except for the parameters for TextField. The first parameter for it is the text label, the second one is what appears in the input box, and the third one says what kind of data the input box accepts. By default, I set the timer to 5 minutes. Also, by setting the third parameter to TextField.NUMERIC, the program will check the input for me and make sure that the input was in fact all numbers. The documentation told me that the constant to use was TextField.NUMBER, but I think that is deprecated. The setLayout method is for just setting the GUI elements to the center of the screen.

The last three lines just tells the program to add these GUI elements to the screen. The elements will appear in the order that they’re written.

The startApp(), pauseApp(), and destroyApp() Methods

When the program starts and the constructor code finishes running, the startApp method is invoked. The code here is very easy. All it does is that tells the MIDlet what Form to use for the display.

public void startApp()
{
Display.getDisplay(this).setCurrent(GUI);
}

public void destroyApp(boolean unconditional)
{

}

public void pauseApp()
{

}

Each MIDlet contains its own “Display”, which is defined by the Display class. This object contains information on what form to display to the user. Although I never tried, it should be possible to switch between different Forms. For more information about the Display class, see the references.

The other two methods are empty because there is no code that I needed to have run while the program is in the paused and destroyed states. They appear because these methods must be overridden.

The commandAction() Method

This method is run when a button is pressed. This is where the commandListener comes in. When a command is invoked by the user, the commandListener will know what happened and call the commandAction method.

public void commandAction(Command c, Displayable s)
{
if (c == cmdExit)
{
notifyDestroyed();
}
else if (c == cmdStart)
{
if (Integer.parseInt(tfVibrateInterval.getString()) > 0)
{
count = Integer.parseInt(tfVibrateInterval.getString()) * 60;
timer.schedule(timerTask, 0, 1000);
}
}
}

When the method is invoked, the command object involved is passed to this method and we can use this to determine what to do for each button. Here I set up if statements to check that if the exit button is pressed, the program will terminate, and that if the start button is pressed, I should start the timer. More information about the timer code is below.

The Timer

Once the program starts, the timer will activate. The value to countdown from is taken from the input box (see above code). In order to get the Timer to do its work, the schedule method must be called with three parameters. One is what task to perform at each interval, how many iterations of the timer to do, and how often to run the code. To set up the task, the TimerTask class must be extended.

private class TimerCountdown extends TimerTask
{
public final void run()
{
String minutes = "";
String seconds = "";

minutes = String.valueOf(count / 60);
if (count % 60 >= 10)
{
seconds = String.valueOf(count % 60);
}
else
{
seconds = "0" + String.valueOf(count % 60);
}


strTime.setLabel("n" + minutes + ":" + seconds);

if (count == 0)
{
count = Integer.parseInt(tfVibrateInterval.getString()) * 60;
vibratePhone();
}

count--;
}
}

I put this code inside the class I was working with, so I ended up with a class within a class. The extended class must override the run method. This method is what defines the code that runs at every timer interval. Here, I just put code to count down the time and to write on the screen how long until the next vibration will occur. Once the count reaches zero, the vibratePhone method will be called, the timer is reset. See the references for an example program that uses a timer.

Vibrating the Phone

The actual vibrate method is included in the Display class, I couldn’t put that code with the run method. I solved that problem by putting the code in a different method and calling it.

public void vibratePhone()
{
Display.getDisplay(this).vibrate(VIBRATE_DURATION);
}

The vibrate duration is in milliseconds. By default, I have mine set to 800 ms and I did not set up a way for the user to change this while running the program. The reference discussing the Display class includes information about the vibrate method.

Testing

Once all the code is in place, press the run button. If the Wireless Toolkit and the devices were set up properly, the emulator should turn on. Play around with it. Once the countdown goes to zero, a buzzing sound will play to signal that the phone vibrated.

Packaging the App

Once everything works, we need to package the program so that it can be used on the phone and not just on the computer.

Editing the JAD file

When I first tried to install the program on my phone, my phone kept complaining about how it couldn’t read the files properly. It turns out I was missing a line in my JAD file. Open the JAD file for the app with a text editor. It is located in the root directory for the project. Add a new line somewhere in the file like below:

MIDlet-1: WakeUp,,WakeUpMIDlet

The this line provides a description on the program’s name, icon, and name of the class. I was missing this before, so the program refused to work. It also helps to modify the content of the other lines to show the author and what not. For more information see Reference 18.

Packaging

This is the last step in the development of the application.

  1. Go to the Project Explorer
  2. Right click the project
  3. Expand the menu for J2ME
  4. Create Package

Once that is done, a JAR and JAD file will appear in the folder called “deployed” in the project directory. Copy these files to the phone and then execute them on the phone. The app should install and be runnable. There are lots of options for packaging the app like using Antenna, obfuscation, and signing, but I’m not cover those topics here. The references will have more information. This concludes the application development process for the Java Mobile Platform.

Code Download

For this app, I registered a project on SourceForge.

Project Information: https://sourceforge.net/projects/periodicvibrate/
Download: http://sourceforge.net/projects/periodicvibrate/files/WakeUp.zip/download

Sources

Here are a bunch of links that I used to gather information on how to do everything I talked about here.

[1] JDK Download Page

This is for those who don’t already have the JDK installed. People who already program Java should already have this installed.

https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/ViewProductDetail-Start?ProductRef=jdk-6u24-oth-JPR@CDS-CDS_Developer

[2] Eclipse Download Page

The site to download the free IDE for Java development

http://www.eclipse.org/downloads/

[3] Sun Java Wireless Toolkit Download Page

The site to download the Sun Java Wireless Toolkit

http://www.oracle.com/technetwork/java/index-jsp-137162.html

[4] EclipseME Installation Instructions

Has information on how to obtain, install, and set up EclipseME

http://eclipseme.org/docs/installEclipseME.html

[5] EclipseME Device Management

Provides instructions how to set up the emulation devices for the IDE so that the programmer can perform software testing

http://eclipseme.org/docs/advDeviceMgmt.html

[6] Explanation of the J2ME and MIDlets

Provides an explanation of what MIDlets and J2ME are all about. The site is also a tutorial on programming using the J2ME.

http://today.java.net/pub/a/today/2005/02/09/j2me1.html

[7] Wireless Development Tutorial

A tutorial on wireless development on the Java Mobile platform. It also includes instructions on setting up a development environment (different than mine), and a sample “Hello World” program.

http://developers.sun.com/mobility/midp/articles/wtoolkit/

[8] The CommandListener Interface

The documentation for the CommandListener Interface.

http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/lcdui/CommandListener.html

[9] MIDP GUI Programming

Has a good explanation of the classes involved in programming a GUI. It also explains a lot of other GUI elements that I didn’t use in my program.

http://oreilly.com/catalog/wirelessjava/chapter/ch05.html

[10] The Form Class

The documentation for the Form class.

http://java.sun.com/javame/reference/apis/jsr037/javax/microedition/lcdui/Form.html

[11] The Command Class

The documentation for the Command class.

http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/lcdui/Command.html

[12] The TextField Class

The documentation for the TextField class.

http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/lcdui/TextField.html

[13] The StringItem Class

The documentation for the StringItem class.

http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/lcdui/StringItem.html

[14] The Timer Class

The documentation for the Timer class.

http://download.oracle.com/javase/1.4.2/docs/api/java/util/Timer.html

[15] The TimerTask Class

The documentation for the TimerTask class.

http://download.oracle.com/javase/1.5.0/docs/api/java/util/TimerTask.html

[16] The Display Class

The documentation for the Display class.

http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/lcdui/Display.html

[17] J2ME Timer MIDlet Example

Contains an example program for how to use timers in a MIDlet

http://www.roseindia.net/j2me/timer-midlet.shtml

[18] Wireless Application Programming: MIDP Programming and Packaging Basics

Contains information on how to package the application and how to edit the JAD file so that the program will work on the phone.

http://developers.sun.com/mobility/midp/articles/getstart/

[19] Packaging Your MIDlet Suite

Contains information on how to package the MIDlet with various methods such as using Antenna, obfuscation, and how to sign the app.

http://eclipseme.org/docs/packaging.html

Receiving MMS on Vodafone

Receiving MMS on Vodafone

Up until now, I’ve never opened an MMS successfully. My Internet settings on the phone were never set
probably plus I never bothered to do it. I also didn’t know the billing rates for opening them either.
But now, an opportunity arose for me to require MMS. The Deutsche Bahn has three options for distributing tickets purchased online. The first one is by printing them out, but I don’t have a printer. The second method is having them mailed to me, but that costs 3.50 euro. The third and best option, is to have them sent as MMS. Knowing that my phone, the P1i, has this ability, I looked for how to do it. After going through lots of Googling and reading through translated German sites, I finally figured it out.

Now, I use Vodafone in Germany, but this method may work on other providers even. I am also using GPRS, and not 3G (I don’t have a dataplan unfortunately). The way to do it is to register an account on Vodafone.de using your phone number. Obviously, if you use a different provider, you’d go to their website to make the account. I clicked through their services and found an option called the “HandyKonfigurator”. What it does is it sends me the proper settings required for my phone. I clicked through the dropdown boxes, found my phone and pressed continue. Vodafone then sent me a file that would inject the settings into my phone. They also sent me a PIN that I had to enter before my phone settings were changed. I did as I was asked, and now I can receive MMS messages!

Vodafone Internet Account Settings

  • Address: event.vodafone.de
  • No user name and password required
  • IP Config and DNS Addresses are set to automatic
  • Proxy Server: 139.7.29.17 at port 80

Vodafone MMS Account Settings

  • Service Center Address: http://139.7.24.1/servlets/mms

Free Texting/SMS (Online Services and E-mail)

Personal note:  I did notice that if I tried e-mailing a Fido or Rogers number, the recipient will not receive the message you sent, and instead they will get a message telling them how to retrieve the message.  It seems like a convoluted way of doing things.  It works perfectly with Bell Mobility.  Replies get sent to your inbox too.
  • Rogers Wireless: [10-digit phone number]@pcs.rogers.com
  • Fido: [10-digit phone number]@fido.ca
  • Telus: [10-digit phone number]@msg.telus.com
  • Bell Mobility: [10-digit phone number]@txt.bell.ca
  • Kudo Mobile: [10-digit phone number]@msg.koodomobile.com
  • MTS: [10-digit phone number]@text.mtsmobility.com
  • President’s Choice: [10-digit phone number]@txt.bell.ca
  • Sasktel: [10-digit phone number]@sms.sasktel.com
  • Solo: [10-digit phone number]@txt.bell.ca
  • Virgin: [10-digit phone number]@vmobile.ca

http://smartcanucks.ca/how-to-send-free-text-messages-to-rogers-fido-telus-bell-virgin-cell-phones-canada/

© 2017 Henry Poon's Blog

Theme by Anders NorénUp ↑