0

hey guys i am doing a basic program and i want to add an mp3 file in the setContentView file if i use setContentView(R.layout.yoyo) "yoyo my mp3 file name" i got errors actually i created a sub folder in "lib" as "raw" in which my mp3 file "yoyo" was placed. so i gave setContentView(R.raw.yoyo) the error was gone but when i stimulate in the emulator there are errors

Installation failed due to invalid URI!
[2014-07-26 11:35:49 - Firstone] Please check logcat output for more details.
[2014-07-26 11:35:50 - Firstone] Launch canceled!

my Log cat out put

07-26 18:52:15.958: W/ActivityManager(1263): Activity destroy timeout for ActivityRecord{b2209a10 u0 com.firstone/.Splash t7 f}
07-26 18:52:34.779: W/linker(1756): libdvm.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
07-26 18:52:36.829: E/memtrack(1756): Couldn't load memtrack module (No such file or directory)
07-26 18:52:36.829: E/android.os.Debug(1756): failed to load memtrack module: -2
07-26 18:52:38.489: W/linker(1767): libdvm.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
07-26 18:52:40.319: E/memtrack(1767): Couldn't load memtrack module (No such file or directory)
07-26 18:52:40.319: E/android.os.Debug(1767): failed to load memtrack module: -2
07-26 18:52:41.219: I/ActivityManager(1263): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.firstone/.Splash} from pid 1767 on display 0
07-26 18:52:41.719: E/libEGL(938): called unimplemented OpenGL ES API
07-26 18:52:41.729: E/libEGL(938): called unimplemented OpenGL ES API
07-26 18:52:41.729: E/libEGL(938): called unimplemented OpenGL ES API
07-26 18:52:41.729: E/libEGL(938): called unimplemented OpenGL ES API
07-26 18:52:41.729: E/SurfaceFlinger(938): glCheckFramebufferStatusOES error 779177132
07-26 18:52:41.729: E/SurfaceFlinger(938): got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot

07-26 18:52:41.729: E/libEGL(938): called unimplemented OpenGL ES API
07-26 18:52:41.729: E/libEGL(938): called unimplemented OpenGL ES API
07-26 18:52:41.879: W/WindowManager(1263): Screenshot failure taking screenshot for (123x164) to layer 21000
07-26 18:52:42.119: I/Choreographer(1263): Skipped 809 frames!  The application may be doing too much work on its main thread.
07-26 18:52:42.289: I/Choreographer(1263): Skipped 203 frames!  The application may be doing too much work on its main thread.
07-26 18:52:42.459: I/Choreographer(1263): Skipped 142 frames!  The application may be doing too much work on its main thread.
07-26 18:52:42.699: I/Choreographer(1263): Skipped 267 frames!  The application may be doing too much work on its main thread.
07-26 18:52:42.799: I/Choreographer(1263): Skipped 92 frames!  The application may be doing too much work on its main thread.
07-26 18:52:42.989: I/Choreographer(1263): Skipped 31 frames!  The application may be doing too much work on its main thread.
07-26 18:52:43.219: I/Choreographer(1263): Skipped 30 frames!  The application may be doing too much work on its main thread.
07-26 18:52:43.399: I/Choreographer(1263): Skipped 30 frames!  The application may be doing too much work on its main thread.
07-26 18:52:43.519: E/Region(938): Region::boolean_operation(op=7) invalid Rect={60,-10,180,-170}
07-26 18:52:51.949: W/ActivityManager(1263): Launch timeout has expired, giving up wake lock!
07-26 18:52:52.119: E/WindowManager(1263): Starting window AppWindowToken{b20e20d0 token=Token{b22a9080 ActivityRecord{b20e1c08 u0 com.firstone/.Splash t8}}} timed out

MY JAVA CODE IS

package com.firstone;

import android.app.Activity;
import android.os.Bundle;

public class Splash extends Activity {

    @Override
    protected void onCreate(Bundle GaryNeeds) {
        // TODO Auto-generated method stub
        super.onCreate(GaryNeeds);
        setContentView(R.raw.yoyo);
    }

}

MY XML CODE IS

Carlos J
  • 2,965
  • 4
  • 17
  • 28
  • setContentView should be used with a value from R.layout. You can't use R.raw with it. – Ian Newson Jul 25 '14 at 18:40
  • possible duplicate of [Unfortunately MyApp has stopped. How can I solve this?](http://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this) – Code-Apprentice Jul 25 '14 at 18:49
  • if i use a R.layout."the file name" the error pops up"yoyo cannot be resolved or is not a field" – Gary Girish Jul 26 '14 at 05:13
  • but i have the mp3 file as "yoyo" in lib\raw\yoy – Gary Girish Jul 26 '14 at 05:25
  • I'm not sure what you're trying to do, but you can't use an mp3 file as a layout. You need to produce an XML layout file and put it in R.layout, which you can then pass to setContentView. Maybe if you explain what you're trying to achieve someone can give you more specific guidance. – Ian Newson Jul 26 '14 at 11:08
  • This question seems to be related to what you're trying to achieve, and includes some code that may help you: http://stackoverflow.com/questions/15346199/how-to-play-and-stop-an-mp3-file-in-an-android-app – Ian Newson Jul 26 '14 at 11:11

1 Answers1

0

setContentView should be used with a value from R.layout. You can't use R.raw with it.

Have a read of the following documentation:

http://developer.android.com/reference/android/app/Activity.html#setContentView(int)

Ian Newson
  • 7,679
  • 2
  • 47
  • 80