[Q] MX Player returns null in onActivityResult - MX Player

My code is
Code:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage("com.mxtech.videoplayer.ad");
intent.setType("application/mp4");
intent.setData(uri);
intent.putExtra("position", 0);
intent.putExtra("return_result", true);
startActivityForResult(intent, PLAY_CODE);
Why onActivityResult method receives null in intent data?
Also onActivityResult always receives result code RESULT_CANCELED.

marievych said:
My code is
Code:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage("com.mxtech.videoplayer.ad");
intent.setType("application/mp4");
intent.setData(uri);
intent.putExtra("position", 0);
intent.putExtra("return_result", true);
startActivityForResult(intent, PLAY_CODE);
Why onActivityResult method receives null in intent data?
Also onActivityResult always receives result code RESULT_CANCELED.
Click to expand...
Click to collapse
I've run exact sample code but onActivityResult() returned RESULT_OK.
Check if uri is valid, if it is not pointing to a valid file, RESULT_CANCLED might be return.

bleu8888 said:
I've run exact sample code but onActivityResult() returned RESULT_OK.
Check if uri is valid, if it is not pointing to a valid file, RESULT_CANCLED might be return.
Click to expand...
Click to collapse
My uri is correct.
Can you try this uri?
Code:
Uri uri = Uri.parse("http:\\vs8*videoprobki*com*ua/tvukrbud/cam19.mp4");
And what about returning intent?

marievych said:
My uri is correct.
Can you try this uri?
Code:
Uri uri = Uri.parse("http:\\vs8*videoprobki*com*ua/tvukrbud/cam19.mp4");
And what about returning intent?
Click to expand...
Click to collapse
Replace "\\" with "//" and "*" with"."

marievych said:
Replace "" with "//" and "*" with"."
Click to expand...
Click to collapse
Works with no problem. resultCode is RESULT_OK and data is not null.
Tried following code:
Code:
String url = "YOUR_URL;
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage("com.mxtech.videoplayer.ad");
intent.setType("application/mp4");
intent.setData(uri);
intent.putExtra("position", 0);
intent.putExtra("return_result", true);
startActivityForResult(intent, 111);
Did you check logcat log? "return_result" should be printed out if the playback activity received intent extra correctly.

bleu8888 said:
Works with no problem. resultCode is RESULT_OK and data is not null.
Tried following code:
Code:
String url = "YOUR_URL;
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage("com.mxtech.videoplayer.ad");
intent.setType("application/mp4");
intent.setData(uri);
intent.putExtra("position", 0);
intent.putExtra("return_result", true);
startActivityForResult(intent, 111);
Did you check logcat log? "return_result" should be printed out if the playback activity received intent extra correctly.
Click to expand...
Click to collapse
Problem resolved by manual rewriting my code. What was wrong remaining mystery

I have exactly the same problem but I can't solve it. This is the way I create my Intent :
Code:
Uri uri = Uri.parse("http: // 172.20.0.101/media_directory/videos_10000319/videos_10000319_playlist_main.m3u8");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage("com.mxtech.videoplayer.ad");
intent.setDataAndType(uri, "application/mp4");
intent.putExtra(EXTRA_RETURN_RESULT, true);
startActivityForResult(intent, REQUEST_CODE_MXPLAYER);
The onActivityResult() methode i called with the correct requestCode but the resultCode is always RESULT_CANCELED and the intent is null..
As you can see, the Uri is a local network address, can it be the problem ?

kserin said:
I have exactly the same problem but I can't solve it. This is the way I create my Intent :
Code:
Uri uri = Uri.parse("http: // 172.20.0.101/media_directory/videos_10000319/videos_10000319_playlist_main.m3u8");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage("com.mxtech.videoplayer.ad");
intent.setDataAndType(uri, "application/mp4");
intent.putExtra(EXTRA_RETURN_RESULT, true);
startActivityForResult(intent, REQUEST_CODE_MXPLAYER);
The onActivityResult() methode i called with the correct requestCode but the resultCode is always RESULT_CANCELED and the intent is null..
As you can see, the Uri is a local network address, can it be the problem ?
Click to expand...
Click to collapse
There are spaces before and after "//". Can MX play this url?

bleu8888 said:
There are spaces before and after "//". Can MX play this url?
Click to expand...
Click to collapse
Spaces are not actually present in my code (I add it here just to avoid my code be considered as SPAM).

kserin said:
Spaces are not actually present in my code (I add it here just to avoid my code be considered as SPAM).
Click to expand...
Click to collapse
Would you share logcat log? MX would leave some information.

Related

[Solved] findViewById Returns Null?

Hi all,
I'm in the process of adding more features to Contacts.apk (http://forum.xda-developers.com/showthread.php?t=599194), and have run into a "bug" with my latest attempt in adding the green call icon to the Contacts list (similar to Call Log), so that you can dial directly without first tapping on a Contact.
I've posted the problem here: http://www.anddev.org/viewtopic.php?p=31252 and would really appreciate if you all could give me some pointers.
Thank you .
Also, the main issue is:
view.findViewById(R.id.call_icon);
is returning null for some reason.
Note: My github does not contain the source with this problem, please go to the anddev thread and download it from there. Thanks!
Did you pull your pants down then try? It worked for me last time
try typecasting callView
I only looked briefly ... sooo ...
How is callView defined in ContactsListActivity.java?
github doesn't show it ....
Code:
final static class ContactListItemCache {
public TextView nameView;
public CharArrayBuffer nameBuffer = new CharArrayBuffer(128);
public TextView labelView;
public CharArrayBuffer labelBuffer = new CharArrayBuffer(128);
public TextView numberView;
public CharArrayBuffer numberBuffer = new CharArrayBuffer(128);
public ImageView presenceView;
public ImageView photoView;
}
Also, consider a matching return type before the function call ... something like I dunno ...
Code:
public View newView(Context context, Cursor cursor, ViewGroup parent) {
final View view = super.newView(context, cursor, parent);
final ContactListItemCache cache = new ContactListItemCache();
cache.nameView = (TextView) view.findViewById(R.id.name);
cache.labelView = (TextView) view.findViewById(R.id.label);
cache.numberView = (TextView) view.findViewById(R.id.number);
cache.presenceView = (ImageView) view.findViewById(R.id.presence);
cache.photoView = (ImageView) view.findViewById(R.id.photo);
- cache.callView = view.findViewById(R.id.call_icon);
+ cache.callView = (DontPressWithParentImageView ) view.findViewById(R.id.call_icon);
if (cache.callView == null)
Log.d("NULL: CALLVIEW", "Why?");
view.setTag(cache);
return view;
}
I could be off base here ... but since the git appears incomplete in relation to your posted problem ... etc ... best I can do in a quick drive by. Hope it helps.
~enom~
enom: If you go to the anddev thread I've attached the full (non-working, bugged) source. In it:
Code:
final static class ContactListItemCache {
public TextView nameView;
public CharArrayBuffer nameBuffer = new CharArrayBuffer(128);
public TextView labelView;
public CharArrayBuffer labelBuffer = new CharArrayBuffer(128);
public TextView numberView;
public CharArrayBuffer numberBuffer = new CharArrayBuffer(128);
public ImageView presenceView;
public ImageView photoView;
public View callView;
}
jasonpeinko: I did that already, not working. The main issue here is view.findViewById(R.id.call_icon) is returning null .
Thanks for the help guys!
So ... I must be blind ... I don't see the attached bugged source ... still could be off base here ... but ...
Since call_icon is type View, should it not be as such in the xml ...
Code:
/>
- <com.android.contacts.ui.widget.DontPressWithParentImageView android:id="@+id/call_icon"
+ <View android:id="@+i/call_icon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
??
Either way, it's late I need sleep.
~enom~
enom: Nope. View is the base class so be it a Button, ImageButton, etc, they can still be assigned to View... .
did you call
Code:
setContentView(R.layout.main);
before your findViewById?
Camalot i understand thats the usual approach but in this case the content view is already set by the constructor in the code. I will give your advice a shot later, but i will be really confused if it works. Thanks!
I found the bug. It's because the layout in use was contacts_list_item_photo.xml and not contacts_list_item. *smacks head*
Thanks for the input guys !

[Q] Multiple Alarms

Hi ,
I am looking for someone to assist me with a problem that i have with multiple alerts .
i have created pending intents with different requestCode but i do not know how to catch this code in my broadcast handler
here is the relevant code :
Intent intent = new Intent(PROXIMITY_ALERT);
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 123, intent , PendingIntent.FLAG_CANCEL_CURRENT);
lm.addProximityAlert(30.28006245, 31.85403462, 200, -1, pendingIntent);
thanks !

[Resolved] [Q][DEV]Android Development Question about Shared Preferences.

Hi, I'm trying to do a simple login with Facebook in my app but I'm having trouble with Shared Preferences.
The idea is to start the app, it opens Activity A, checks if it's logged, and if it isn't, it sends you to activity B, you login and then go back to A.
My problem is that I can't get the SharedPreferences. I can save it, but I can't get it in the other activity.
So, it gets in a loop: A can't get the SP, so thinks it's not logged in, so send you to B, but B is logged on, and sends you to A...
That's my code in B:
Code:
public void onComplete(Bundle values) {
// TODO Auto-generated method stub
Editor edit = fbSP.edit();
edit.putString("access_token", fb.getAccessToken());
edit.putLong("access_expires", fb.getAccessExpires());
edit.commit();
aIMG();
ir();
}
And that's my code in A, where the problem is:
Code:
private SharedPreferences prefs;
public static String TOKEN = null;
public static final String FACEBOOK_DATA = "FacebookStuff";
long EXPIRES = 0;
...
private void SharedP() {
// TODO Auto-generated method stub
prefs = getSharedPreferences(FACEBOOK_DATA, MODE_PRIVATE);
TOKEN = prefs.getString("access_token", null);
EXPIRES = prefs.getLong("access_expires", 0);
if (TOKEN == null && EXPIRES == 0) { //If it's not logged in...
Intent login = new Intent("android.intent.action.FACELOGIN");
startActivity(login);
}
}
Edit: I got it. I was iniciating fbSP with getPreferences, not getSharedPreferences.

Application for notify when your flat is power-less

Hi everyone
I was searching one app for android, but i cannot find any like that.
Basically i need to understand when my flat went down on electricity
beacuse i have food in the fridge, fish in the acquarium or whatever you may have.
I was thinking i could leave a currently unused phone on charge in the wall socket.
When electricity goes off the phone stop charging and it can notify me with email.
Do you think something like that exist?
A general event driven notifier that support email would be fine.
Is there anything like that? on the market even a paid app?
Best regards, Andrea
You could try using Tasker for it.
"To err is human, to forgive is divine"
Sent from my SGS II
Tasker do half of the job...
it detects what i need, it compose the email...
but it cannot send it!!!
It can open a web url directly, so i can program a simple php script to send an email.
But if i could do without a webserver helping me it would be better.
I think that SMS notification will be more reliable in this case. Anyway all that you need is a very simple app, probably no more than several lines of code. If you are still interested in this I can help you to write one (if you have at least basic programming knowledge) or write one for you.
qubas said:
I think that SMS notification will be more reliable in this case. Anyway all that you need is a very simple app, probably no more than several lines of code. If you are still interested in this I can help you to write one (if you have at least basic programming knowledge) or write one for you.
Click to expand...
Click to collapse
solved with tasker. i make it open weburl, on web url i made application that send email.
cause tasker compose but cannot send.
i have programming knowledge,i would like to start,i just don t like java
maybe just a problem of mine
do you have some empty app franework to look at?
asturur said:
solved with tasker. i make it open weburl, on web url i made application that send email.
cause tasker compose but cannot send.
i have programming knowledge,i would like to start,i just don t like java
maybe just a problem of mine
do you have some empty app franework to look at?
Click to expand...
Click to collapse
There are many tutorials for installing Android Development Tools (ADT) and creating simple "Hello world" app. It probably takes 1 hour to do that. For simple app you don't really have to know Java, copy-paste some code samples from the Internet should do the trick, you just need to have at least some basic programming knowledge.
I still think that sending SMS is the most reliable solution. Using Wifi is a bad idea, because it won't work when there is no AC, unless you have a UPS. With 3G its much better, but still you have to rely on the web service you use to send email.
Anyway, here is my code:
Code:
package com.example.powermonitoring;
import android.os.BatteryManager;
import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.telephony.SmsManager;
import android.widget.Toast;
public class MainActivity extends Activity {
private static final String NUMBER = "+48123456789";
private static final int THRESHOLD = 10;
private static final String AC_ONLINE = "AC is back online!";
private static final String AC_OFFLINE = "AC is offline!";
private Handler handler = new Handler();
private int counter;
private boolean lastPowerState;
private boolean powerState;
private Runnable runnable = new Runnable() {
[user=439709]@override[/user]
public void run() {
powerState = isPlugged(MainActivity.this);
if (powerState != lastPowerState) {
counter++;
if (counter == THRESHOLD) {
counter = 0;
lastPowerState = powerState;
String message;
if (powerState) {
message = AC_ONLINE;
} else {
message = AC_OFFLINE;
}
Toast.makeText(MainActivity.this, message, Toast.LENGTH_SHORT).show(); //for testing
//SmsManager sms = SmsManager.getDefault();
//sms.sendTextMessage(NUMBER, null, message, null, null);
}
}
handler.postDelayed(this, 1000);
}
};
public static boolean isPlugged(Context context) {
Intent intent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
return plugged == BatteryManager.BATTERY_PLUGGED_AC || plugged == BatteryManager.BATTERY_PLUGGED_USB;
}
[user=439709]@override[/user]
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lastPowerState = isPlugged(MainActivity.this);
handler.postDelayed(runnable, 1000);
}
}
You just have to remember about including permission in AndroidManifest.xml :
Code:
<uses-permission
android:name="android.permission.SEND_SMS"
/>

global varible for application

I need a global varible for my android application.is there a good way to do this ?
I have several activities.I need to use this variable for all these activities.
asliyanage said:
I need a global varible for my android application.is there a good way to do this ?
I have several activities.I need to use this variable for all these activities.
Click to expand...
Click to collapse
You mean you need code for this?
I need a example.
Pass variables as intent parameters when you start an activity ie:
Code:
Intent i = new Intent(this, ActivityClass.class);
i.putExtra("myvar","value");
startActivity(i);
then read variable using (if it is a string)
Code:
Intent i = getIntent(); // gets the previously created intent
String myvar = i.getStringExtra("myvar");

Categories

Resources