我正在编写一个Android应用程序,当我尝试使用广播接收器检测图片(ScreenShot)时遇到问题。 我做了一个类,CameraEventReceiver:
package studio.pomme.m.the33.Autres;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.util.Log;
import android.widget.Toast;
public class CameraEventReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context arg0, Intent arg1) {
Log.i("INFO", "Enter BroadcastReceiver");
Cursor cursor = arg0.getContentResolver().query(arg1.getData(), null, null, null, null);
cursor.moveToFirst();
String image_path = cursor.getString(cursor.getColumnIndex("_data"));
Toast.makeText(arg0, "New Photo is Saved as : " + image_path, Toast.LENGTH_SHORT).show();
}
}
清单中的整数:
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<application
android:allowBackup="true"
android:icon="@drawable/indice"
android:label="33"
android:theme="@style/Theme.AppCompat.NoActionBar">
<receiver class = "studio.pomme.m.the33.Autres.CameraEventReceiver"
android:name=".Autres.CameraEventReceiver"
android:enabled="true" >
<intent-filter>
<action android:name="studio.pomme.m.the33.Level.Level25" />
<action android:name="android.hardware.action.Level25" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</receiver>
</application>
应用程序从这里开始:
<activity
android:name=".Level.Level25"
android:screenOrientation ="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
我希望我能找到你的问题...... 谢谢!