×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Super Contributor
    Join Date
    Nov 2010
    Posts
    1,216

    Cool How to set internet and apn settings i.e app should ask user at start up of the App

    How to set internet and apn settings i.e app should ask user at start up of the App i.e

    It should ask to user select the wi fi access ponts or 3G gprs i.e apn settings at the start up of the app.




    I have built a MIDlet project using java ME class which parses the contents of url ending with xml.aspx and shows channel images , channel names

    with the following code MainMidlet.java


    Code:
     package mypackage;
    
    
    import java.io.*;
    import java.util.*;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.io.*;
    import javax.xml.parsers.*;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    
    class Channel {    
    	public String cName;    
    	public String cId;    
    	public String cType;
    	public String cLanguage;
    	public String cImage;
    	public String cLink;
    	public String cBandwidth;
    	public String cCellnapid;
    }
    
    class ChannelListHandler extends DefaultHandler {    
    
    	Channel currentChannel;
    	private String lastCharacters;   
    	
    	private Vector channelList;     
    	
    	public ChannelListHandler() {        
    		channelList = new Vector();    
    	}     
    	
    	public Channel[] getChannels() {       
    		Channel[] channels = new Channel[channelList.size()];        
    		channelList.copyInto(channels);        
    		return channels;    
    	}
    	
    	public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {    
    		if (qName.equals("channel")) {        
    			currentChannel = new Channel();    
    			}
    		}
    	
    	public void characters(char[] ch, int start, int length) throws SAXException {    
    		lastCharacters = new String(ch, start, length).trim();
    		} 
    	
    	public void endElement(String uri, String localName, String qName) throws SAXException {    
    		if (qName.equals("name")) {        
    			currentChannel.cName=lastCharacters;    		
    		} else if (qName.equals("id")) {        
    			currentChannel.cId=lastCharacters;    		
    		} else if (qName.equals("type")) {        
    			currentChannel.cType=lastCharacters;    		
    		} else if (qName.equals("language")) {        
    			currentChannel.cLanguage=lastCharacters;    		
    		} else if (qName.equals("image")) {        
    			currentChannel.cImage=lastCharacters;    		
    		} else if (qName.equals("link")) {        
    			currentChannel.cLink=lastCharacters;    		
    		} else if (qName.equals("bandwidth")) {        
    			currentChannel.cBandwidth=lastCharacters;    		
    		} else if (qName.equals("cellnapid")) {        
    			currentChannel.cCellnapid=lastCharacters;    
    			channelList.addElement(currentChannel);
    			currentChannel=null;
    		}
    	}	
    }
    
    public class MainMidlet extends MIDlet implements CommandListener, Runnable {     
    	private Form form;     
    	
    	public void startApp() {        
    		if (form == null) {            
    			form = new Form("Demo");            
    			form.addCommand(new Command("Exit", Command.EXIT, 0));            
    			form.setCommandListener(this);             
    			// start parsing            
    			(new Thread(this)).start();        
    			}        
    		Display.getDisplay(this).setCurrent(form);    
    		}     
    	
    	public void pauseApp() {}     
    		
    	public void destroyApp(boolean must) {}     
    	
    	public void commandAction(Command c, Displayable d) {        
    		if (c.getCommandType() == Command.EXIT) {            
    			notifyDestroyed();        
    			}    
    		}  
    	
    	public Image loadImage(String url) throws IOException {
    	    HttpConnection hpc = null;
    	    DataInputStream dis = null;
    	    Image image = null;   
    	    try {
    	      hpc = (HttpConnection) Connector.open(url);
    	      int length = (int) hpc.getLength();
    	      byte[] data = new byte[length];
    	      dis = new DataInputStream(hpc.openInputStream());
    	      dis.readFully(data);	      
    	      try {
    	    	  image = Image.createImage(data, 0, data.length);
    	      } catch (IllegalArgumentException e) {}
    	    } catch (Exception e) {            
    	    } finally {
    	      if (hpc != null) hpc.close();
    	      if (dis != null) dis.close();   
    	    }
    	    return image;
    	}
    	    
    	public void run() {        
    		try {            	
    			ChannelListHandler handler = new ChannelListHandler();                       
    			SAXParser parser = SAXParserFactory.newInstance().newSAXParser();             
    			
    			Channel[] channels = null;
    			HttpConnection con = null;
    			InputStream ins = null;
    			
    			try {
    				con = (HttpConnection)Connector.open("http://yupptv.com/mobile/symbianxmlnew.aspx");
    				ins = con.openInputStream();           
    				parser.parse(ins, handler);
    			 } catch (Exception e) {            
    				 form.append(e.toString());        
    			 }	finally {             		
    				 channels = handler.getChannels(); 
    				 if (con != null) con.close();
    				 if (ins != null) ins.close();
    			 }
    			
    			if (channels != null && channels.length > 0) {
    				for (int i = 0; i < channels.length; i++) {
    					form.append(channels[i].cName);
    					Image image = loadImage(channels[i].cImage);
    					if ( image == null ) form.append("\nInvalid image link!\n");
    					else form.append(new ImageItem(null, image, ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_NEWLINE_BEFORE | ImageItem.LAYOUT_NEWLINE_AFTER, ""));
    				}
    			} else {               
    				form.append("(no channels)\n");           
    			}
    		} catch (Exception e) {            
    			form.append(e.toString());        
    		}	
    	}
    }


    And the output is as follows

    java app.jpg

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,684

    Re: How to set internet and apn settings i.e app should ask user at start up of the A

    http://developer.nokia.com/Resources...Networkprompts says there is no general support for that. However it also says it is possible to mark WLAN access point to connect automatically.
    A few lines lower in the contents there is http://developer.nokia.com/Resources...state-api.html, you may consider checking if it has any use for you (not sure).

  3. #3
    Super Contributor
    Join Date
    Nov 2010
    Posts
    1,216

    Re: How to set internet and apn settings i.e app should ask user at start up of the A

    Network prompts

    Nokia Asha and Series 40 software platform devices does not generally support access point selection. In devices that support WLAN, access point selection is prompted when WLAN is available and no WLAN tagged as "automatic" is found.



    Yes WLAN access point selection works for me How to implemnt it.


    Now Iam going thru

    http://developer.nokia.com/Resources...e-changes.html

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,684

    Re: How to set internet and apn settings i.e app should ask user at start up of the A

    Quote Originally Posted by GTO_India View Post
    Yes WLAN access point selection works for me How to implemnt it.
    I think it is not something to implement, when user configures access points on his/her device, that may be the place to set something like "connect to this access point automatically".

  5. #5
    Super Contributor
    Join Date
    Nov 2010
    Posts
    1,216

    Re: How to set internet and apn settings i.e app should ask user at start up of the A

    Iam canfused about invoking the WLAN or wi fi listener


    i.e App asking the user to select the wi access point etc

  6. #6
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105

    Re: How to set internet and apn settings i.e app should ask user at start up of the A

    Quote Originally Posted by GTO_India View Post
    It should ask to user select the wi fi access ponts or 3G gprs i.e apn settings at the start up of the app.
    Why?
    In Series 40 and new Asha Software Platform all this is done automatically for you. If your real device does not go for Wi-Fi automatically (or does not ask), then your phone is not configured correctly. If you face this, we have to look into why your phone misbehaves. Therefore, do you face a configuration issue?

  7. #7
    Super Contributor
    Join Date
    Nov 2010
    Posts
    1,216

    Re: How to set internet and apn settings i.e app should ask user at start up of the A

    Iam facing this issue real device is going for wi-fi automatically and wi fi is configured already on my device but i WANT MY APP to ASK FOR THE WIFI access points etc.



    Thanks
    Last edited by GTO_India; 2014-01-15 at 10:38.

  8. #8
    Nokia Developer Moderator
    Join Date
    Oct 2006
    Location
    Finland
    Posts
    4,535

    Re: How to set internet and apn settings i.e app should ask user at start up of the A

    Quote Originally Posted by GTO_India View Post
    Iam facing this issue real device is going for wi-fi automatically and wi fi is configured already on my device but i WANT MY APP to ASK FOR THE WIFI access points etc.



    Thanks
    It will connect to whatever is configured. Your app wont be able to ask seperately.

  9. #9
    Super Contributor
    Join Date
    Nov 2010
    Posts
    1,216

    Re: How to set internet and apn settings i.e app should ask user at start up of the A

    Ok Actually iam not getting the correct output in my Java application

Similar Threads

  1. Settings for internet & email?
    By ekotracks in forum Wired and Wireless interfaces (Closed)
    Replies: 1
    Last Post: 2010-10-14, 03:02
  2. Internet Tel. Settings of the device.
    By lal.rajan in forum Symbian Networking & Messaging (Closed)
    Replies: 23
    Last Post: 2008-10-27, 17:37
  3. How to send OTA settings for Internet
    By talluritrk in forum OMA DM/DS/CP
    Replies: 0
    Last Post: 2004-11-06, 07:18
  4. OMA CP + internet settings
    By pisotalo in forum Smart Messaging
    Replies: 0
    Last Post: 2004-07-07, 11:10

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×