Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8460033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:29:41+00:00 2026-06-10T13:29:41+00:00

I am a beginner in Android I am trying to develop Set Wallpaper App.After

  • 0

I am a beginner in Android I am trying to develop Set Wallpaper App.After clicking on image second activity will open.Here is my code:

manifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myfirstapplication"
    android:versionCode="1"
    android:versionName="1.0" >
     <uses-sdk
        android:minSdkVersion="7"
        android:targetSdkVersion="15" />

   <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".secondActivity"
                  android:label="@string/app_name">
        </activity>
    </application>

</manifest>

activity_main.xml

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="wrap_content"
     android:layout_height="fill_parent"
     android:orientation="vertical"
     android:paddingLeft="8dp"
     android:paddingRight="8dp" >

     <ImageView
         android:id="@+id/imageView1"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:src="@android:drawable/btn_star_big_on"
         android:clickable="true"  
         android:onClick="imageClick"  />

     <TextView
         android:id="@android:id/empty"
         android:layout_width="150dp"
         android:layout_height="wrap_content"
         android:text="Wallpaper" />
 </LinearLayout>

main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="wrap_content"
     android:layout_height="fill_parent"
     android:orientation="vertical"
     android:paddingLeft="8dp"
     android:paddingRight="8dp" >

    <Button
        android:id="@+id/set"
        android:layout_width="298dp"
        android:layout_height="70dp"
        android:text="Set Wallpaper" />


    <Button
        android:id="@+id/hoti"
        android:layout_width="fill_parent"
        android:layout_height="193dp"
        android:text="HOTI" />

    <Button
        android:id="@+id/smb"
        android:layout_width="298dp"
        android:layout_height="70dp"
        android:text="See More" />
    <Button
        android:id="@+id/quit"
        android:layout_width="298dp"
        android:layout_height="70dp"
        android:text="Quit" />
 </LinearLayout>

MainActivity.java

package com.example.myfirstapplication;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends Activity {

 @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }


public void imageClick(View v){

    //Create an intent to start the new activity.
       // Our intention is to start secondActivity
    Intent intent = new Intent();
    intent.setClass(this,secondActivity.class);
    startActivity(intent);
   }
}

secondActivity.java

package com.example.myfirstapplication;

import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;


public class secondActivity extends Activity {
    Bitmap bitmap;
   /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

     // Set the layout for this activity
        setContentView(R.layout.main);


        Button btn1 = (Button) findViewById(R.id.quit);
        btn1.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                finish();
                System.exit(0);
            }
        });
        }

}

After clicking on set wallpaper button the file chooser should open from which I can choose image and also I can see preview of that image and can set it as a wallpaper.Please help me out.
I also want to open a popup window after clicking on “see more” button.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:29:43+00:00Added an answer on June 10, 2026 at 1:29 pm

    showFileChooser() method will do this for you.
    Hope u get ur requirment.

     private void showFileChooser() {
                Intent intent = new Intent(Intent.ACTION_GET_CONTENT); 
                intent.setType("*/*"); 
                intent.addCategory(Intent.CATEGORY_OPENABLE);
    
                try {
                    startActivityForResult(
                            Intent.createChooser(intent, "Select a Image"), FILE_SELECT_CODE);
                } catch (android.content.ActivityNotFoundException ex) {
                    Toast.makeText(this, "Please install a File Manager.",Toast.LENGTH_SHORT).show();
                }
            }
    
            @Override
            protected void onActivityResult(int requestCode, int resultCode, Intent data) {
                super.onActivityResult(requestCode, resultCode, data);
                switch (requestCode) {
                    case FILE_SELECT_CODE:      
                    if (resultCode == RESULT_OK) {  
    
                        Uri uri = data.getData();
                        String path = getRealPathFromURI(uri);
                        File imgFile = new File(path);
                        if(imgFile.exists())
                        {
                           myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
                           img.setImageBitmap(myBitmap);
                        }
    
                    }           
                    break;
                }
            }
    
            /**
             * Returns path of the file specified by content Uri
             */
            public String getRealPathFromURI(Uri contentUri) {
                String[] proj = { MediaStore.Images.Media.DATA };
                Cursor cursor = managedQuery(contentUri, proj, null, null, null);
                int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
                cursor.moveToFirst();
                String path = cursor.getString(column_index);
                cursor.close();
                return path;
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a beginner android programmer who is trying to set up some USB functionality
the tutorial here http://www.edumobile.org/android/android-beginner-tutorials/creating-image-gallery/ teaches how to put images from resources in gallery here's
I'm just a beginner with android and trying to develope an app with all
I'm a beginner in java/android but I am trying to make an app. A
I am trying to create an android app that will let me display images
I'm just a beginner with android. I want to divide a bitmap image into
I'm a beginner android developer , I was trying to run this Linear Layout
I am a beginner to android and have designed a login GUI for app
i am beginner in Android app development i am working on a app which
I am a beginner android developer and I am trying to have a button

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.