Click here to Skip to main content
15,886,840 members
Articles / Mobile Apps / Android

Android + iOS Torch sample

Rate me:
Please Sign up or sign in to vote.
3.91/5 (10 votes)
12 Dec 2013CPOL2 min read 37.4K   1.7K   23  
Samples for present Android and iOS to control torch.
  • LEDTestiOS.zip
    • __MACOSX
    • LEDTest
      • .git
        • branches
        • COMMIT_EDITMSG
        • config
        • description
        • HEAD
        • hooks
          • applypatch-msg.sample
          • commit-msg.sample
          • post-commit.sample
          • post-receive.sample
          • post-update.sample
          • pre-applypatch.sample
          • pre-commit.sample
          • prepare-commit-msg.sample
          • pre-rebase.sample
          • update.sample
        • index
        • info
          • exclude
        • logs
          • HEAD
          • refs
            • heads
              • master
        • objects
          • 20
            • 59258a640749de32f19af24982a357cfd6a575
          • 21
            • f5b223805546bbb8f19bcd14972e85a46f444d
          • 25
            • 9eea026377261f89fa1b5ed23cdc7a9737e4c5
          • 3c
            • c7366d7d34ebd722580dc0f09ac5f8d3c46c78
          • 41
            • 4cf11935983cc7d2e4f60a248c70dddcc3507d
          • 43
            • a0e18bb4f78ad2ba56f7a3009e1e3f1336679f
          • 47
            • 2123d075f4fed9c105839734d341a5a30fdb3c
            • 7b28ff8f86a3158a71c4934fbd3a2456717d7a
          • 4f
            • c69ef4b6aa4ec38934cb7d66c5ee8b743eea16
          • 78
            • 1bb3d7f0b70d1307a64b3bf1b6c5768e8afe10
          • 90
            • 0ca4cad10ef5f66cc99bc2f4381dc68b372e7d
          • 91
            • bfdbd9a1b6eb54db8b27d3908b78724a589a5f
          • a4
            • f2449ead07a97e65dd34214c281626a6b9f5f8
          • a9
            • 4e4bc8567c7377a726ba199278b310019e2db0
          • e7
            • 178e4d5666a3b75aa48de33b966f0590665a8e
          • info
          • pack
        • refs
          • heads
            • master
          • tags
      • LEDTest.xcodeproj
        • project.pbxproj
        • project.xcworkspace
          • contents.xcworkspacedata
          • xcuserdata
            • mac.xcuserdatad
              • UserInterfaceState.xcuserstate
        • xcuserdata
      • LEDTest
  • LEDTestAndroid.zip
    • .classpath
    • .project
    • .settings
      • org.eclipse.jdt.core.prefs
      • AndroidManifest.xml
      • assets
      • bin
        • classes.dex
        • classes
          • com
            • clouddevelop
              • ledtest
                • CloudLed.class
                • LEDTestActivity$1.class
                • LEDTestActivity$2.class
                • LEDTestActivity.class
                • R$attr.class
                • R$drawable.class
                • R$layout.class
                • R$string.class
                • R.class
        • com
          • clouddevelop
            • ledtest
              • CloudLed.class
              • LEDTestActivity.class
              • R$attr.class
              • R$drawable.class
              • R$layout.class
              • R$string.class
              • R.class
        • LEDTest.apk
        • res
          • drawable-hdpi
            • icon.png
          • drawable-ldpi
            • icon.png
          • drawable-mdpi
            • icon.png
        • resources.ap_
      • gen
        • com
      • proguard.cfg
      • project.properties
      • res
        • drawable-hdpi
          • icon.png
        • drawable-ldpi
          • icon.png
        • drawable-mdpi
          • icon.png
        • layout
        • values
      • src
package com.clouddevelop.ledtest;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

public class LEDTestActivity extends Activity {
	
	LinearLayout m_layout;
	private Button m_btnOn;
	private Button m_btnOff;
	
	CloudLed m_led;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.main);
        m_layout = new LinearLayout(this);
		m_btnOn = new Button(this);
		m_btnOn.setText("ON");
		m_btnOn.setWidth(300);
		m_btnOff = new Button(this);
		m_btnOff.setText("OFF");
		m_btnOff.setWidth(300);
		m_led = new CloudLed();
		m_btnOn.setOnClickListener(new Button.OnClickListener(){
			 public void onClick(View v) {
			    // TODO Auto-generated method stub
				 m_led.turnOn();
			 }});
		m_btnOff.setOnClickListener(new Button.OnClickListener(){
			 public void onClick(View v) {
			    // TODO Auto-generated method stub
				 m_led.turnOff();
			 }});
		m_layout.setHorizontalFadingEdgeEnabled(false);
		m_layout.setVerticalFadingEdgeEnabled(true);
		m_layout.addView(m_btnOff);
		m_layout.addView(m_btnOn);
        setContentView(m_layout);  
    }

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		m_led.turnOff();
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect SIS
Taiwan Taiwan
CloudBox cross-platform framework. (iOS+ Android)
Github: cloudhsu
My APP:
1. Super Baby Pig (iOS+Android)
2. God Lotto (iOS+Android)
2. Ninja Darts (iOS)
3. Fight Bingo (iOS)

Comments and Discussions