几周前我决定制作一个应用程序,这个应用程序只包含视频链接,允许用户在点击任何按钮链接时观看剪辑.
我正在使用此代码播放视频:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("http://www.yourvideo.mp4"), "video/mp4");
view.getContext().startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
但是,在某些情况下,此代码在多个设备中不起作用,我的应用程序的某些用户表示,只要按下任何链接,它就会强制关闭整个应用程序.我实际上在我的G1和Droid X中试过它,它工作得非常好.
有什么我做错了吗?请帮助我,我会非常感激.
我正在尝试calendar
从一个片段插入事件,但我一直收到错误,没有发现任何活动来处理Intent.
这是错误 -
android.content.ActivityNotFoundException:找不到处理Intent的Activity {act = android.intent.action.INSERT cat = [android.intent.category.APP_CALENDAR] typ = vnd.android.cursor.item/event(has extras)}
这是我的代码:
Intent intent = new Intent(Intent.ACTION_INSERT);
intent.addCategory(Intent.CATEGORY_APP_CALENDAR);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra(Events.TITLE, "Phototherapy Treatment");
intent.putExtra(Events.EVENT_LOCATION, "");
intent.putExtra(Events.DESCRIPTION, "Phototherapy Treatment");
// Setting dates
Calendar calDate = Calendar.getInstance();
intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,calDate.getTimeInMillis());
intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME,
calDate.getTimeInMillis()+60*60*1000);
// Make it a full day event
intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, false);
// Make it a recurring Event
intent.putExtra(Events.RRULE, "FREQ=WEEKLY;COUNT="+Integer.valueOf(No.getText().toString())+";"
+"WKST=SU;BYDAY="+days);
// Making it private and shown as busy
intent.putExtra(Events.ACCESS_LEVEL, Events.ACCESS_PRIVATE);
intent.putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
意图过滤器
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.INSERT" …
Run Code Online (Sandbox Code Playgroud) 美好的一天.我有一个奇怪的问题,堆栈溢出中没有任何例子工作.我正在打开一个画廊,之后我将用户重定向到crop crop.Important提到这只发生在Android N而不是设备之下.问题是,一旦作物完成就会抛出这个异常.我不知道是什么原因造成的,但实际上这就是我如何开始作物意图.
Intent cropIntent = new Intent("com.android.camera.action.CROP");
cropIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
Uri outPutUri = FileProvider.getUriForFile(activity, activity.getApplicationContext().getPackageName() + ".provider", new File(output));
Uri photoURI = FileProvider.getUriForFile(activity, activity.getApplicationContext().getPackageName() + ".provider", new File(path));
activity.grantUriPermission("com.android.camera.action.CROP", outPutUri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
activity.grantUriPermission("com.android.camera.action.CROP", photoURI, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
cropIntent.setDataAndType(photoURI, "image/*");
cropIntent.putExtra("crop", "true");
cropIntent.putExtra("aspectX", aspectX);
cropIntent.putExtra("aspectY", aspectY);
cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, outPutUri);
activity.startActivityForResult(cropIntent, CROP_REQUEST);
Run Code Online (Sandbox Code Playgroud)
我已授予Uri许可,已将这些添加到清单中
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
Run Code Online (Sandbox Code Playgroud)
我已经尝试了所有堆栈流程回答示例,没有更多关于堆栈溢出的问题与这个场景并没有任何工作.所以android N的问题是什么?它应该这么难吗?
这是抛出的异常
FATAL EXCEPTION: main
Process: com.android.gallery3d, PID: 5735
java.lang.SecurityException: Permission Denial: writing android.support.v4.content.FileProvider uri content://my.package.name/external_files/Android/data/my.package.name/cache/0.5062300225583558.png from pid=5735, uid=10071 …
Run Code Online (Sandbox Code Playgroud) android crop android-intent android-securityexception android-7.0-nougat
实际上,我正在尝试创建一个包含n个多媒体文件的应用程序,其中包括图像和视频.我的应用规模大约是34MB
,我的资产规模大约是60mb
.当我在正常设备上加载应用程序时,我们没有遇到任何问题,但是具有2K resolutions
诸如此类的设备Nexus 6P, HTC, LG
,应用程序在进程中间因"内存不足"错误而崩溃.我用这个产生了错误报告.我也尝试过bitmap factory.同时我在数组方法中使用视频.
有人可以帮忙解决这个问题吗?
致命异常:主程序:com.example.we.appname,PID:9353
java.lang.OutOfMemoryError:无法在android.graphics上的android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)的dalvik.system.VMRuntime.newNonMovableArray(Native Method)中分配带有1243880个空闲字节和1214KB的1660396字节分配. android.graphtent.decodeStream(BitmapFactory.java:620)位于android.content.res.ResourcesImpl的android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:455)android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1155) .loadDrawableForCookie(ResourcesImpl.java:720)在android.content.res上的android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:571)android.content.res.Resources.loadDrawable(Resources.java:858).在android.graphics.drawable上的android.graphics.drawable.AnimationDrawable.Arfable(可动画衍生事件中,动画可伸缩. .DrawableInflater.inflat android.content.res.ResourcesImpl上android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1227)的android.graphics.drawable.Drawable.createFromXml(Drawable.java:1200)中的eFromXml(DrawableInflater.java:130) .loadDrawableForCookie(ResourcesImpl.java:715)位于android.content.res.Resources上的android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:571)android.content.Context的android.content.res.Resources.getDrawable(Resources.java:771). android.app.Activity.performCreate的com.example.kq.meettheshps.Score_Card.onCreate(Score_Card.java:58)上的android.view.View.setBackgroundResource(View.java:18228)中的getDrawable(Context.java:525) (Activity.java:6679)在Android.app.ActivityThread.perleLaunchActivity(ActivityThread.java:2618)的android.app.Instrumentation.callActivityCnate(Instrumentation.java:1118)android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: 2726)android.app.ActivityThread.-wrap12(ActivityThread.java)在android.app.ActivityThread $ H.handleMessage(ActivityT)hread.java:1477)android.app.Handler.dispatchMessage(Handler.java:102)android.app.Looper.loop(Looper.java:154)android.app.ActivityThread.main(ActivityThread.java:6119) )at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:886)的com.android.internal.os.ZygoteInit.main(ZygoteInit)中的java.lang.reflect.Method.invoke(Native Method)的.java:776)
我想我已经尝试了所有东西(使焦点成为可能:假!!)并且无论如何我无法捕捉列表项目中的所选复选框.即使是OnItemClickListener,也不会响应任何点击.
如何在列表项中检索选中的复选框?我的列表项包括:图像视图,4个文本视图和复选框
一些代码:
这是在我的ListActivity类中:
final String columns[] = new String[] { MyUsers.User._ID,
MyUsers.User.MSG, MyUsers.User.LOCATION };
int[] to = new int[] { R.id.toptext, R.id.bottomtext,R.id.ChkBox, R.id.Location};
Uri myUri = Uri.parse("content://com.idan.datastorageprovider/users");
Cursor cursor = getContentResolver().query(myUri, columns, null, null, null);
startManagingCursor(cursor);
ListCursorAdapter myCursorAdapter=new ListCursorAdapter(this,
R.layout.listitem, cursor, columns, to);
this.setListAdapter(myCursorAdapter);
Run Code Online (Sandbox Code Playgroud)
这是我的Custom Cursor适配器类:
public class ListCursorAdapter extends SimpleCursorAdapter
{
private Context context;
private int layout;
public ListCursorAdapter(Context context, int layout, Cursor c,
String[] from, int[] to)
{
super(context, layout, c, from, to);
this.context = context;
this.layout …
Run Code Online (Sandbox Code Playgroud) 我正在使用Sherlock Fragment,如果应用程序在最小化再次打开应用程序时打开对话框,我就会崩溃.
以下是我的例外情况:
Stack trace java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1360)
android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1378)
android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:595)
android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:574)
android.support.v4.app.DialogFragment.dismissInternal(DialogFragment.java:200)
android.support.v4.app.DialogFragment.dismiss(DialogFragment.java:166)
com.alts.asterride.BookingDialogFragment$4$1.run(BookingDialogFragment.java:325)
android.os.Handler.handleCallback(Handler.java:730)
android.os.Handler.dispatchMessage(Handler.java:92)
android.os.Looper.loop(Looper.java:137)
android.app.ActivityThread.main(ActivityThread.java:5493)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:525)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025)
dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)
提前致谢.
我正在使用ft.commitAllowingStateLoss(); comit片段.
这是我的预订对话框代码
mBookingDialogFragment.dismiss();
CabBookingFlow cabBookingFlow = new CabBookingFlow();
cabBookingFlow.setCancelable(false);
cabBookingFlow.show();
Run Code Online (Sandbox Code Playgroud) 我正在开发一个应用程序,其中我添加了一个名为"更多应用程序"的按钮,我想要的是当用户点击该按钮时它应该重定向到显示我的帐户的应用程序列表的游戏商店.我做了以下代码:
String url_more_app = "https://play.google.com/store/search?q=rajesh%20panchal&hl=en";
case R.id.btn_more_app:
Intent viewIntent =
new Intent("android.intent.action.VIEW",
Uri.parse(url_more_app ));
startActivity(viewIntent);
break;
Run Code Online (Sandbox Code Playgroud)
但是当点击该按钮显示我的应用程序的应用程序列表以及其他人的应用程序时,我如何只显示我的应用程序?
我正在尝试在 android 中实现 Firebase,对此我有一些疑问,如果您能帮助我,我将很高兴。陷入其中有点困惑。这是我的问题。
我正在显示 Firebase 聊天,listview
其中我只想从 Firebase 加载第一条 100 条消息,然后用户将pull-to-refresh
加载第一条 200 条消息,依此类推。
为此,我正在寻找limitToFirst()
但limitToLast()
不知道哪一个更好。
任何人都可以帮忙吗?
我似乎无法让它工作,我已经尝试了很多不同的东西,解析工作正常并返回一个arraylist中的标题列表,我无法让它们在ListView上查看.这是代码;
/**
* Created by Matt on 4/21/2015.
*/
public class Discussion_Fragment extends Fragment {
View rootview;
ListView listView;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootview = inflater.inflate(R.layout.discussion_layout, container, false);
ArrayList<String> titles = new ArrayList<String>();
listView = (ListView) rootview.findViewById(R.id.listView1);
parse(getHTTP("https://www.reddit.com/r/DotA2.json?limit=10"));
for(int i=0;i<titles.size();i++){
titles.add(titles.get(i));
}
ArrayAdapter saAdapter = new ArrayAdapter(getActivity(), R.layout.discussion_layout, titles);
listView.setAdapter(saAdapter);
return rootview;
}
public static String getHTTP(String urlToRead) {
URL url;
HttpURLConnection conn;
BufferedReader rd;
String line;
String result = "";
boolean response …
Run Code Online (Sandbox Code Playgroud) 我想计算 List 中物品的价格并将值存储在sharedpreference
. 每个项目都有一个采用双精度形式的价格。问题是当我使用我的方法时,它只考虑列表中的一个项目并计算该值。我正在使用 aNumberPicker
来更改项目的数量。
这是我的适配器,用于处理将显示在 上的项目列表RecyclerView
:
public class CartAdapter extends RecyclerView.Adapter<CartAdapter.ViewHolder> {
private List<SingleItem> items;
private SessionManager sessionManager;
private Context context;
private int pos;
public CartAdapter() {
}
public CartAdapter(Context context, List<SingleItem> items) {
this.items = items;
this.context = context;
sessionManager = new SessionManager(context);
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.cartitem, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(final ViewHolder holder, final int position) { …
Run Code Online (Sandbox Code Playgroud) android for-loop android-recyclerview android-sharedpreferences