Android Open Source - TheNewBoston Photo






From Project

Back to project page TheNewBoston.

License

The source code is released under:

Eclipse Public License - v 1.0 THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECI...

If you think the Android project TheNewBoston listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.homelysoft.thenewboston;
//  w w  w .j a  v a 2 s .  co m
import java.io.IOException;
import java.io.InputStream;

import android.app.Activity;
import android.app.WallpaperManager;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.Toast;

public class Photo extends Activity implements View.OnClickListener {
  private static final int CAMERA_DATA = 0;
  ImageButton ib;
  Button b;
  ImageView iv;
  Intent i;
  Bitmap bitmap;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.photo);
    bridgeXML();
    setOnClickListeners();
    InputStream inputStream=getResources().openRawResource(R.drawable.splash);
    bitmap=BitmapFactory.decodeStream(inputStream);
  }

  private void bridgeXML() {
    ib = (ImageButton) findViewById(R.id.ib_camera);
    iv = (ImageView) findViewById(R.id.iv_returned_picked);
    b = (Button) findViewById(R.id.b_select_wallpaper);
  }

  private void setOnClickListeners() {
    ib.setOnClickListener(this);
    b.setOnClickListener(this);

  }

  @Override
  public void onClick(View view) {
    switch (view.getId()) {
    case R.id.b_select_wallpaper:
      try {
        WallpaperManager wallpapermanager = WallpaperManager
            .getInstance(this);
        wallpapermanager.setBitmap(bitmap);
      } catch (IOException e) {
        Toast.makeText(Photo.this, "Ooops, couldn't set the wallpaper",
            Toast.LENGTH_LONG).show();
        e.printStackTrace();
      }
      break;
    case R.id.ib_camera:
      i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
      startActivityForResult(i, CAMERA_DATA);
      break;
    }
  }

  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK) {
      if (requestCode == CAMERA_DATA) {
        Bundle extras = data.getExtras();
        bitmap=(Bitmap) extras.get("data");
        iv.setImageBitmap(bitmap);
      }
    }
  }

}




Java Source Code List

com.homelysoft.thenewboston.AboutUs.java
com.homelysoft.thenewboston.Accelerate.java
com.homelysoft.thenewboston.Data.java
com.homelysoft.thenewboston.Email.java
com.homelysoft.thenewboston.ExternalData.java
com.homelysoft.thenewboston.Flipper.java
com.homelysoft.thenewboston.Home.java
com.homelysoft.thenewboston.HotOrNot.java
com.homelysoft.thenewboston.InternalData.java
com.homelysoft.thenewboston.OpenedClass.java
com.homelysoft.thenewboston.OurViewClient.java
com.homelysoft.thenewboston.Photo.java
com.homelysoft.thenewboston.Preferences.java
com.homelysoft.thenewboston.SQLView.java
com.homelysoft.thenewboston.SQLite.java
com.homelysoft.thenewboston.SharedPrefs.java
com.homelysoft.thenewboston.Slider.java
com.homelysoft.thenewboston.SoundPoolPlay.java
com.homelysoft.thenewboston.Splash.java
com.homelysoft.thenewboston.StartingPoint.java
com.homelysoft.thenewboston.Tabs.java
com.homelysoft.thenewboston.TextPlay.java
com.homelysoft.thenewboston.gfx.GFXSurface.java
com.homelysoft.thenewboston.gfx.GFX.java
com.homelysoft.thenewboston.gfx.MyBringBack.java
com.homelysoft.thenewboston.vect.Vector.java