×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Registered User
    Join Date
    May 2013
    Posts
    270

    How to use Accelerometer feature of asha 310 in app

    I am making apps for s40 and read that asha 310 is having accelerometer. I want the shake functionality in my phone so that whenever user shakes the phone i will show him some random values of my app. Like if he shakes right i will put a logic to show that values and visa versa for left side . but how to use accelerometer in coding ?

    Plz help with some code examples

  2. #2
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,142

    Re: How to use Accelerometer feature of asha 310 in app

    have you checked our wiki already ? something like this might help: http://developer.nokia.com/Community...ors_in_Java_ME

  3. #3
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    602

    Re: How to use Accelerometer feature of asha 310 in app

    There you go http://developer.nokia.com/Community...apps_in_JavaME comes fully with source code and exact shake logic for shaking a pair of dice.
    and the best thing... its written by me

  4. #4
    Registered User
    Join Date
    May 2013
    Posts
    270

    Re: How to use Accelerometer feature of asha 310 in app

    Thanks shai !

  5. #5
    Registered User
    Join Date
    May 2013
    Posts
    270

    How to use accelerometer

    I am working on s40 app. My app displays a form which has next and previous buttons . When i press them (say right side button or u can say next button) my date shuffles one step right and its corresponding thought is displayed on textarea at center and vica versa functionality on pressing previous button.

    I want to shake the phone such that a random value of date should appear and corresponding to it thought should appear. I took one form in which all my UI is there. So shaking is such that form should remain there.. only value of date label and corresponding thought change(that too random).

    How to get this functionality. I was not able to get the functionality according to my code. I read some tutorials.

    Plz help
    Last edited by Manpreet_Singh; 2013-07-31 at 13:34.

  6. #6
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,142

    Re: How to use accelerometer

    have you considered on checking wiki for articles ? here's one to get you started on the topic: http://developer.nokia.com/Community...ors_in_Java_ME

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,567

    Re: How to use accelerometer

    Merged with your older identical discussion. As you see, the answer does not change just because you re-ask a question. Jukka: the answer is no, Manpreet does not consider neither check.

  8. #8
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,142

    Re: How to use accelerometer

    yep, and I managed to forgot that he was asking this 4 days ago already..

  9. #9
    Registered User
    Join Date
    May 2013
    Posts
    270

    Re: How to use accelerometer

    I managed to check many articles . Infact shai z article was helpful(i got to undertand something about shaking).I tried to put logics to use it my way in my app and was facing problems. i am confused in network sensor . I read yukka z tutorial that day only and infact rest of the tutorials too which were under that zip file. but anyways thanks maybe i skipped something . I will try it once more
    Last edited by Manpreet_Singh; 2013-08-01 at 07:46.

  10. #10
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,142

    Re: How to use accelerometer

    and if you do have problems on specific issues, you should start new thread, specifying on what you have tried sofar, and what do you expect to happen, and what is instead happening, i.e. define the problem in details. Asking for generic help over again wont really get you forward too much

  11. #11
    Registered User
    Join Date
    May 2013
    Posts
    270

    Re: How to use accelerometer

    Thanks yes

  12. #12
    Registered User
    Join Date
    May 2013
    Posts
    270

    I am using accelerometer code and facing some problems . Plz help

    I am making app for s40 and i read about accelerometer basic code and done the following. plz guide me how to use shake motion in x and y direction . I have gone through some tutorials that were suggested in earlier post plus ball rotation code .

    I only want to show form on shake motion which will contain my text area , so that on each shake ,values gonna come from vectors(and display on text area) where i saved my data.

    Here is my code. What are things i need to do in it

    Code:
    public class testacc extends MIDlet {
    	 Form form;
    	
    	private SensorConnection accSensor;
    
      double speedX,speedY;
    	
    	public testacc() {
    		
    		// TODO Auto-generated constructor stub
    	}
    
    	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
    		// TODO Auto-generated method stub
    
    	}
    
    	protected void pauseApp() {
    		// TODO Auto-generated method stub
    
    	}
    
    		private void working_Sensors() {
    		try {
    			
    			Data[] data = accSensor.getData(1);
    			
    			    speedX = data[0].getDoubleValues()[0];
    			   
    			   speedY = -data[1].getDoubleValues()[0];
    			
    			 
    		 } catch (IOException ex) {
    			 ex.printStackTrace();
    		 }
    		 }
    	
    	public void get_Sensors() {
    		
    		 SensorInfo[] sensorInfos = SensorManager.findSensors("acceleration", null);
    		 System.out.println(sensorInfos .length);
    		 for(int i=0;i<sensorInfos .length;i++)
    		 {
    			 System.out.println("valuse of i is"+sensorInfos[i]);
    		 }
    		 if (sensorInfos.length == 0) {
    			 return;
    		 };
    		 try {
    			 for (int i = 0; i < sensorInfos.length; i++){
    				 if (sensorInfos[i].getChannelInfos()[0].getDataType() == ChannelInfo.TYPE_DOUBLE){
    					 accSensor = (SensorConnection)
    							 Connector.open(sensorInfos[i].getUrl());
    					 System.out.println("control reached");
    				 }}}catch (IOException ex) {
    					 ex.printStackTrace();
    				 }
    		  }
    protected void startApp() throws MIDletStateChangeException {
    	
    		 {
    				Display d=Display.getDisplay(this);
    		get_Sensors();
    		working_Sensors();
    		 form=new Form("myform");
    		 
    		// how to work with x and y values ??????
    	d.setCurrent(form);
    			 }
    		// TODO Auto-generated method stub
    
    	}
    	}
    Last edited by wizard_hu_; 2013-08-10 at 13:25. Reason: [QUOTE]-> [CODE]

  13. #13
    Registered User
    Join Date
    May 2013
    Posts
    270

    Re: I am using accelerometer code and facing some problems . Plz help

    .......anyone?

  14. #14
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    602

    Re: I am using accelerometer code and facing some problems . Plz help

    You were given a lot of good articles with full source code to read they have everything you need in them, including getting the X, Y & Z
    You cannot expect us to completly write you the entire code everytime, you have to learn it yourself.

  15. #15
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,142

    Re: I am using accelerometer code and facing some problems . Plz help

    Basically we here can not design the full logic for you. Anyway, you could check the code suggested in #3, it shows nicely that you get the data from accelerator sensor to your dataReceived, and then you would just need to design some kind of logic to use teh acceleration data, in that example there is Math-library used for that purpose.

    Anyway, there are no sensors dedicated to UI controls, i.e. its device accelerometer sensor, thus it measures the device movements. and you would need to then use the rawish data in the way you need it to be used.

Page 1 of 2 12 LastLast

Similar Threads

  1. Accelerometer
    By nettserf in forum Python
    Replies: 3
    Last Post: 2010-06-09, 10:24
  2. help using accelerometer
    By nettserf in forum Python
    Replies: 2
    Last Post: 2010-04-01, 16:42
  3. Accelerometer hw
    By mstrug in forum Symbian C++
    Replies: 1
    Last Post: 2009-10-08, 05:27
  4. Accelerometer
    By bukster1000 in forum General Development Questions
    Replies: 17
    Last Post: 2009-04-03, 10:51
  5. Accelerometer
    By mikedeklerk in forum Symbian C++
    Replies: 32
    Last Post: 2008-04-29, 15: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
  •