-2

好吧,开始 android 应用程序开发真是太好了。
但是现在发生了一些新的事情!

在用户没有显示任何活动后,该应用程序正在被操作系统强制关闭

它以它而闻名的东西......
现在这只发生在这个屏幕上,而不是主活动屏幕
我已经使用 ListView 这个播放列表活动
现在 - 我想允许屏幕变暗,不禁用它!同时将应用程序保存在内存中!有人能告诉我怎么做吗

protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_playlist);
    // Show the Up button in the action bar.
    setupActionBar();
    ListView playlistView = (ListView)findViewById(R.string.playlistHolder);
    String[] STAR = { "*" };        
        Uri allsongsuri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
        String selection = MediaStore.Audio.Media.IS_MUSIC + " != 0";
        @SuppressWarnings("deprecation")
        Cursor cursor = managedQuery(allsongsuri, STAR, selection, null, null);
        File musicstorage = new File("assets/music.xml");
     // Create the array list of to do items
            ArrayList<String> playItems = new ArrayList<String>();
            // Create the array adapter to bind the array to the listview
            ArrayAdapter<String> aa;
            aa = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,playItems);
            // Bind the array adapter to the listview.
            playlistView.setAdapter(aa);
        if (cursor != null)
        {
            if (cursor.moveToFirst())
            {
                do
                {
                    String song_name = cursor.getString(cursor
                            .getColumnIndex(MediaStore.Audio.Media.DISPLAY_NAME));
                    int song_id = cursor.getInt(cursor
                            .getColumnIndex(MediaStore.Audio.Media._ID));

                    String fullpath = cursor.getString(cursor
                            .getColumnIndex(MediaStore.Audio.Media.DATA));

                    String album_name = cursor.getString(cursor
                            .getColumnIndex(MediaStore.Audio.Media.ALBUM));
                    int album_id = cursor.getInt(cursor
                            .getColumnIndex(MediaStore.Audio.Media.ALBUM_ID));

                    String artist_name = cursor.getString(cursor
                            .getColumnIndex(MediaStore.Audio.Media.ARTIST));
                    int artist_id = cursor.getInt(cursor
                            .getColumnIndex(MediaStore.Audio.Media.ARTIST_ID));
                    playItems.add(0, song_name);
                    aa.notifyDataSetChanged();
                } while (cursor.moveToNext());
            }
            cursor.close();
        }
}
4

1 回答 1

0

相关问题在这里。此外,对于唤醒锁,请参阅http://developer.android.com/reference/android/os/PowerManager.html。特别是,SCREEN_BRIGHT_WAKE_LOCK根据您的需要可能就足够了。至于应用程序强制关闭的原因,请发布 Logcat相关代码部分。

于 2013-08-10T12:12:30.283 回答