- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试为我的音乐播放器应用程序中的每首歌曲获取专辑封面。但是除了黑屏,没有专辑封面外,我什么也没得到。除了我从未听说过的日志猫错误之外,代码中似乎没有任何错误。
这是包含按钮单击监听器的 Java 文件。在我的应用程序中单击按钮后,我在 logcat 中收到错误: Bacon1.java
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.os.Environment;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
public class Bacon1 extends Activity {
private static final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 1;
private static int RESULT_LOAD_IMAGE = 1;
public ArrayList<HashMap<String, String>> songsList = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bacon1);
Button button4 = (Button) findViewById(R.id.button4);
button4.setOnClickListener(
new Button.OnClickListener()
{
public void onClick(View v) {
buttonClicked(v);
Intent p = new Intent(Bacon1.this,PlayListActivity.class);
startActivity(p);
}
});
}
private void buttonClicked(View view) {
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.READ_EXTERNAL_STORAGE) + ContextCompat
.checkSelfPermission(this,
Manifest.permission.INTERNET)
!= PackageManager.PERMISSION_GRANTED) {
Snackbar.make(view, "Permission not Granted, Requesting permission.", Snackbar.LENGTH_LONG).show();
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.READ_EXTERNAL_STORAGE)) {
Snackbar.make(view, "We need permission to internal storage for displaying songs", Snackbar.LENGTH_LONG).show();
} else {
Snackbar.make(view, "Allow myapp3 to access this device's internal storage", Snackbar.LENGTH_LONG).show();
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
}
}
public void onClick2(View view) {
Intent i = new Intent(
Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, RESULT_LOAD_IMAGE);
}
public void onClick4(View view) {
Intent viewIntent1 = new Intent(Intent.ACTION_VIEW);
File file = Environment.getExternalStorageDirectory();
viewIntent1.setDataAndType(Uri.fromFile(file), "video/*");
startActivity(Intent.createChooser(viewIntent1, null));
}
public void onClick5(View view) {
Intent viewIntent1 = new Intent(Intent.ACTION_VIEW);
File file = Environment.getExternalStorageDirectory();
viewIntent1.setDataAndType(Uri.fromFile(file), "zip/*");
startActivity(Intent.createChooser(viewIntent1, null));
}
public void onClick6(View view) {
Intent viewIntent1 = new Intent(Intent.ACTION_VIEW);
File file = Environment.getExternalStorageDirectory();
viewIntent1.setDataAndType(Uri.fromFile(file), "text/*");
startActivity(Intent.createChooser(viewIntent1, null));
}
public void onClick7(View view) {
Intent viewIntent1 = new Intent(Intent.ACTION_VIEW);
File file = Environment.getExternalStorageDirectory();
viewIntent1.setDataAndType(Uri.fromFile(file), "application/*");
startActivity(Intent.createChooser(viewIntent1, null));
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
switch (requestCode) {
case 1: {
// If request is cancelled, the result arrays are empty.
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Toast.makeText(Bacon1.this, "WRITE_CONTACTS granted", Toast.LENGTH_SHORT)
.show();
} else {
Toast.makeText(Bacon1.this, "WRITE_CONTACTS Denied", Toast.LENGTH_SHORT)
.show();
}
return;
}
// other 'case' lines to check for other
// permissions this app might request
}
}
}
07-11 17:11:04.222 13978-13978/com.example.dell_1.myapp3 E/ExtMediaPlayer-JNI: env->IsInstanceOf fails
07-11 17:11:04.222 13978-13978/com.example.dell_1.myapp3 E/MediaPlayer-JNI: JNIMediaPlayerFactory: bIsQCMediaPlayerPresent 0
07-11 17:11:04.222 13978-13978/com.example.dell_1.myapp3 E/ExtMediaPlayer-JNI: env->IsInstanceOf fails
07-11 17:11:04.222 13978-13978/com.example.dell_1.myapp3 E/MediaPlayer-JNI: JNIMediaPlayerFactory: bIsQCMediaPlayerPresent 0
package com.example.dell_1.myapp3;
import android.app.Activity;
import android.database.Cursor;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import java.io.File;
import java.io.IOException;
import com.bumptech.glide.Glide;
public class PlayListActivity extends Activity {
private String[] mAudioPath;
private MediaPlayer mMediaPlayer;
private String[] mMusicList;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_play_list);
mMediaPlayer = new MediaPlayer();
ListView mListView = (ListView) findViewById(R.id.list);
mMusicList = getAudioList();
ArrayAdapter<String> mAdapter = new ArrayAdapter<>(this,
android.R.layout.simple_list_item_1, mMusicList);
mListView.setAdapter(mAdapter);
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view, int arg2,
long arg3) {
try {
playSong(mAudioPath[arg2]);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
private String[] getAudioList() {
final Cursor mCursor = getContentResolver().query(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
new String[]{MediaStore.Audio.Media.DISPLAY_NAME, MediaStore.Audio.Media.DATA}, null, null,
"LOWER(" + MediaStore.Audio.Media.TITLE + ") ASC");
int count = mCursor.getCount();
String[] songs = new String[count];
mAudioPath = new String[count];
int i = 0;
if (mCursor.moveToFirst()) {
do {
songs[i] = mCursor.getString(mCursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DISPLAY_NAME));
mAudioPath[i] = mCursor.getString(mCursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA));
i++;
} while (mCursor.moveToNext());
}
mCursor.close();
return songs;
}
private void playSong(String path) throws IllegalArgumentException,
IllegalStateException, IOException {
setContentView(R.layout.activity_android_building_music_player);
Log.d("ringtone", "playSong :: " + path);
mMediaPlayer.reset();
mMediaPlayer.setDataSource(path);
//mMediaPlayer.setLooping(true);
mMediaPlayer.prepare();
mMediaPlayer.start();
asd();
}
public void asd() {
ImageView imageView = (ImageView) findViewById(R.id.coverart);
File music = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC);
// Tested with music from Windows 7's c:\Users\Public\Music\Sample Music
String filePath = new File(music, "I love you.mp3").getAbsolutePath();
Glide
.with(this)
.load(new AudioCover(filePath))
.placeholder(R.drawable.adele1)
.error(R.drawable.adele1)
.into(imageView);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="#242424"
android:dividerHeight="1dp"
android:listSelector="@drawable/list_selector" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:id="@+id/player_header_bg"
android:layout_width="fill_parent"
android:layout_height="60dip"
android:layout_alignParentTop="true"
android:background="@layout/bg_player_header"
android:paddingLeft="5dp"
android:paddingRight="5dp">
<TextView
android:id="@+id/songTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:paddingLeft="50dp"
android:text="The Good, The Bad And The Ugly"
android:textColor="#04b3d2"
android:textSize="16dp"
android:textStyle="bold" />
<ImageButton
android:id="@+id/btnPlaylist"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@null"
android:src="@drawable/btn_playlist" />
</LinearLayout>
<LinearLayout
android:id="@+id/songThumbnail"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/player_header_bg"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:gravity="center"
android:paddingBottom="10dp"
android:paddingTop="10dp">
<ImageView
android:id="@+id/coverart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/player_footer_bg"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@layout/bg_player_footer"
android:gravity="center">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:weightSum="1">
<RelativeLayout
android:layout_width="300dp"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/btnPrevious"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2.40"
android:layout_alignParentLeft="true"
android:paddingLeft="10dp"
android:background="@null"
android:src="@drawable/btn_previous" />
<ImageButton
android:id="@+id/btnPlay1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@null"
android:src="@drawable/btn_play"
android:onClick="buttonAction1"/>
<ImageButton
android:id="@+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="250dp"
android:background="@null"
android:src="@drawable/btn_next" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<SeekBar
android:id="@+id/songProgressBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/player_footer_bg"
android:layout_alignLeft="@+id/timerDisplay"
android:layout_alignStart="@+id/timerDisplay"
android:layout_marginBottom="10dp"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:progressDrawable="@drawable/seekbar_progress"
android:thumb="@drawable/download8" />
<LinearLayout
android:id="@+id/timerDisplay"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/songProgressBar"
android:layout_marginBottom="10dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp">
<TextView
android:id="@+id/songCurrentDurationLabel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:textColor="#eeeeee"
android:textStyle="bold" />
<TextView
android:id="@+id/songTotalDurationLabel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:textColor="#04cbde"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/timerDisplay"
android:gravity="center">
<ImageButton
android:id="@+id/btnRepeat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:background="@null"
android:src="@drawable/btn_repeat" />
<ImageButton
android:id="@+id/btnShuffle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="@null"
android:src="@drawable/btn_shuffle" />
</LinearLayout>
</RelativeLayout>
最佳答案
亲爱的程序员们。我重建了这个项目,一切正常,直到你面对 .zip
格式和/或 Uri
部分。
我的建议:
更改.zip
预设。
还要检查您使用的 SDK
s。
我还发现,生成的 Uri
无效使用。
viewIntent1.setDataAndType(Uri.fromFile(file), "zip/*");
它会创建一个无效的
Uri
,尝试使用
.parse
:
Uri file = Uri.parse("/zip");
PS:我认为这也与设备相关。有些得到问题,有些没有。也许它可以帮助你。我认为写一个可能的解决方案比让这个问题死掉要好。 ;)
关于java - logcat 错误 : E/ExtMediaPlayer-JNI: env->IsInstanceOf fails,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44913292/
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 4 年前。 Improve
我在终端中使用“adb -d logcat”来查看我的应用程序日志文件。最近,我遇到了一大堆运行时错误——由于某种原因我看不到所有这些错误。它只是在结尾处以“...30 more”结束: [ 08-1
我的 Logcat 停止与我的“开发者设备”Huawei Y5 一起工作。 我使用完全更新的 Android 3.5.1,直到两天前一切正常,现在突然我的应用程序日志不再显示了。 logcat 显示以
我使用 Eclipse 开发应用程序。当我转到 eclipse 的菜单窗口-> 显示 View -> 其他时,我发现两个项目名为“LogCat”和“LogCat(deprecated)”。 LogCa
我在我的应用程序中使用 Timber 和 DebugTree。我想将所有消息记录到 Firebase 崩溃报告中。 Timber.plant(object : Timber.DebugTree()
在 Moto G 上开发我的应用程序时,我经常遇到数以万计的以下消息淹没日志。 E/MM_OSAL ( 275): isSamePayload Sync byte(0x47) not found!!
在注意到 Android Studio 中没有显示 Logcat 消息后,我尝试了所有解决方案,但都没有奏效。我最终尝试了命令 adb devices 并确定我的设备在那里,但是当我尝试 adb lo
来自命令:C:\android-sdk-windows\platform-tools>adb shell 然后是 logcat -b radio 它打印旧的历史日志。我试着像这样调用 logcat -
我每15分钟就会遇到“blank logcat”或“logcat bug”的问题,随意告诉它! 我知道以下解决方案可以解决此问题: 进入 DDMS 并选择我的设备 => 80% 的情况下,logcat
请原谅我没有以完整尺寸显示 Logcat(到目前为止,我使用的是 RAM 和图形内存有限的 VM)。 每次启动 Eclipse 时,Logcat 都会像这样显示所有这些信息列(红色圆圈)。 现在,我想
我正在尝试运行 react-native log-android 来测试在我的 react-native 手机应用程序上上传谷歌照片。我得到错误 warn The following packages
对于 Android 应用程序,我将日志保存在设备本身上,以便在出现问题时我们可以找出问题所在。此设备在无互联网环境中运行,因此无法远程写入日志。 下面的代码首先清除缓冲区,然后将记录的内容连续写入“
显示 LogCat 几分钟后消失。我从 Window->Preferences->Logcat 中将 LogCat 输出消息的数量更改为 10000。但在读取整个堆栈之前仍然消失。知道为什么会发生这种
我有一些与 Android Logcat 相关的问题,我将这些问题称为 REAL DEVICE 而不是模拟器: 我有一个程序有很多 Log.d (或其他类似的日志功能),我做了一些谷歌搜索,发现这些日
我收到很多与我的应用程序相关的此类 logcat 消息。 2019-03-13 10:05:51.065 27319-27319/com.example.fir_s1 I/chatty: uid=10
我正在对一个奇怪的错误进行故障排除,当不良行为发生时,我在 logcat 中看到了这一点。 --------- beginning of system 这是什么意思?我没有找到任何 nativ
我想通过 APPIUM 获取特定标签(例如:testing_aws)的 ADB logcats。实际上我是直接从控制台完成此操作的,如下所示 我导航至 /home/jagadeesh/android-
我刚刚开始使用 android,正在制作一个 webview 应用程序 我的整个计划是显示启动屏幕,直到 webview 加载,然后切换某些内容的可见性,然后使 webview 可见 WebView
我刚刚在运行 Mountain Lion 的 Mac 上安装了 Eclipse 3.8。我打开了 LogCat 窗口并点击最小化,它去了某个地方...... 现在当我点击 Window>Show Vi
我使用 Parse 作为我的应用程序的后端,并且我使用了他们的 quick start guide设置推送通知。 我已经一步一步地跟着它了,没有得到插入。当我启动应用程序时,我还在 logcat 中收
我是一名优秀的程序员,十分优秀!