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 7027507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:15:25+00:00 2026-05-28T00:15:25+00:00

I do simple small programs in android for my practice. While I am on

  • 0

I do simple small programs in android for my practice. While I am on the way to create a simple player app, I had to face an error which I could not solve.The following is my code.

import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class AndrmusiActivity extends Activity {
    /** Called when the activity is first created. */
    public MediaPlayer playr;
    public Button b1;
    public Button b2;
    public Button b3;
    @Override
    public void onCreate(Bundle State) {
        super.onCreate(State);
        setContentView(R.layout.main);
        b1= (Button)findViewById(R.id.play);
        b1.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {                   
            playr = MediaPlayer.create(this,R.raw.showme);
            playr.start();

            }
        });
        b2= (Button)findViewById(R.id.Pause);           
        b2.setOnClickListener(new OnClickListener() {           
            public void onClick(View v1) {                  
                playr.pause();              
            }
        });
        b3=(Button)findViewById(R.id.Stop);            
        b3.setOnClickListener(new OnClickListener() {               
            public void onClick(View v) {                   
                playr.stop();
                playr.reset();

            }
        });

    }
}

Now I faced the error at play method at the line

playr = MediaPlayer.create(this,R.raw.showme);

Could any one please help me in this aspect.
Thanks in adv

  • 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-05-28T00:15:25+00:00Added an answer on May 28, 2026 at 12:15 am

    Use this line there

     playr = MediaPlayer.create(AndrmusiActivity.this,R.raw.showme);
    

    If error remains post your error logcat.

    create this in your on create() method.

     playr = MediaPlayer.create(this,R.raw.showme);
    

    For resume()

    use your your code as same as below.

    b1 = (Button) findViewById(R.id.play);
    b1.setOnClickListener(new OnClickListener() {
             public void onClick(View v) {
                 playr.start();
             }
         });
    

    Calling start() to resume playback for a paused MediaPlayer object, and the resumed playback position is the same as where it was paused. When the call to start() returns, the paused MediaPlayer object goes back to the Started state.

    http://developer.android.com/reference/android/media/MediaPlayer.html#start()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a small and simple android app. I tried installing it on
Does anybody know of any small and simple ajax/php to do lists which I
I have a simple small question which someone who knows will be able to
Good afternoon. I have been making a small openGL based app for android that
I'm working on learning TDD while writing some small ruby programs. I have the
I've stumbled over a seemingly simple problem while building two libraries and test programs
I started with a piece of code which got split into two small programs
I'm writing a small program to record reading progress, the data models are simple:
I am currently building a very small/simple web application in ASP.NET MVC with ADO.NET
Here is my problem. I am trying to write a small simple game engine

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.