Default Messenger app is not Opening - android

I am working on Messages and issue which i am facing here is default messenger app is not opening in Lenovo K8 Note (7.1.1) on tapping the button and this issue occurs only in this device.I analysed forums but i didnt get a proper solution.Suggest me how to resolve this issue.
chat.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
try {
Intent sms = new Intent(Intent.ACTION_VIEW);
sms.setType("vnd.android-dir/mms-sms");
sms.putExtra("sms_body_popup",
getResources()
.getString(R.string.custom_refer_message_chat)
+ "\n" + str_url);
startActivity(sms);
} catch (Exception e) {
Toast.makeText(
getApplicationContext(),
getResources()
.getString(R.string.no_default_apps),
Toast.LENGTH_LONG).show();
}
}
});

To answer your question, Can i expect some code snippet for your query.

Related

How to check if zoom.us and Slack apps are installed on Android?

I'm trying to create an app in Android where a user can install zoom.us and Slack apps and run them but I need to check before installation if the app is already installed or not. The problem is I don't know the names of the packages so I can check against them, What would be the name of packages for zoom.us and slack and How would I run them by click of zoom and slack buttons?
public class MainActivity extends AppCompatActivity {
ImageButton zoom, slack;
Button installZoom, installSlack;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Install zoom
installZoom = (Button) findViewById(R.id.inst_zoom);
if (isZoomClientInstalled(getApplicationContext())) {
installZoom.setEnabled(false);
} else {
installZoom.setEnabled(true);
installZoom.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse("https://play.google.com/store/apps/details?id=us.zoom.videomeetings"));
startActivity(intent);
}
});
}
// Run zoom
zoom = (ImageButton) findViewById(R.id.app_zoom);
zoom.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "About to run zoom", Toast.LENGTH_SHORT).show();
}
});
// Install Slack
installSlack = (Button) findViewById(R.id.inst_slack);
if (isSlckClientInstalled(getApplicationContext())) {
installSlack.setEnabled(false);
} else {
installSlack.setEnabled(true);
installSlack.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse("https://slack.com/downloads/android"));
startActivity(intent);
}
});
}
// Run Slack
slack = (ImageButton) findViewById(R.id.app_slack);
slack.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "About to run Slack", Toast.LENGTH_SHORT).show();
}
});
}// End of Create();
// Determine whether the zoom for Android client is installed on this device.
public boolean isZoomClientInstalled(Context myContext) {
PackageManager myPackageMgr = myContext.getPackageManager();
try {
myPackageMgr.getPackageInfo("???.???.??", PackageManager.GET_ACTIVITIES);
} catch (PackageManager.NameNotFoundException e) {
return (false);
}
return (true);
}
// Determine whether the Slack for Android client is installed on this device.
public boolean isSlackClientInstalled(Context myContext) {
PackageManager myPackageMgr = myContext.getPackageManager();
try {
myPackageMgr.getPackageInfo("???.???.??", PackageManager.GET_ACTIVITIES);
} catch (PackageManager.NameNotFoundException e) {
return (false);
}
return (true);
}
}// End of class
you may find app package by looking into Google Play link
https://play.google.com/store/apps/details?id=com.Slack
com.Slack is package name here. us.zoom.videomeetings for Zoom. Then you just start it with Intent. Try it.
If you know the package name for the app, then you can check that if that app is installed on the device or not.
PACKAGE NAMES:
Zoom.Us: us.zoom.videomeetings
Slack: com.Slack
You know the code for it as stated in the comments. By running it you will know if the app is installed on the device or not.
To check if app is installed or not, you need to know the package name of the app you want to check. You can find the package name of the app from Google play store, focus on URL. Id in URL is the package name.
For Example for Zoom.us it is: us.zoom.videomeetings
Since both apps are well established, it is highly unlikely they will update the package name.

PLACES_API_ACCESS_NOT_CONFIGURED with unrestricted key

I am trying to implement places autocomplete widget in my app, but when I open the widget it instantly closes and outputs in the logcat:
E/Places: Autocomplete widget closing due to PLACES_API_ACCESS_NOT_CONFIGURED
It correctly identifies the key in the AndroidManifest.xml. The API key is unrestricted, so that can't be the problem.
My code:
place.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
try {
Intent intent =
new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY)
.build(getActivity());
startActivityForResult(intent, 1);
} catch (GooglePlayServicesRepairableException e) {
Toast.makeText(getActivity(), "GooglePlayServicesRepairableException",
Toast.LENGTH_LONG).show();
} catch (GooglePlayServicesNotAvailableException e) {
Toast.makeText(getActivity(), "GooglePlayServicesNotAvailableException",
Toast.LENGTH_LONG).show();
}
}
});
So if anyone is facing the same issue, I solved it by going to the API Dashboard and enabling Places SDK for Android. Only enabling the Places API is not enough and the error messages and instructions weren't clear to me.
Thanks. Add following to the AndroidManifest.xml
<meta-data
android:name="com.google.android.places.API_KEY"
android:value=<your api key>/>

"#" not included while sending call (i.e. for mobile phone recharging) In android phone

I want to make recharge process just by entering the recharge number and add up 401 at the beginning and # at last eg: *401*12387263736748# . but call goes like: *401*12387263736748
without "#" included.
RechargeRequestButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
RechargeCode = "*401*"
+ RechargeCodeView.getText().toString()+"#";
Intent RechargeingIntent = new Intent(Intent.ACTION_CALL, Uri
.parse("tel:"+RechargeCode));
try {
startActivity(RechargeingIntent);
finish();
} catch (Exception e) {
Log.e("Exception", e.getMessage());
Toast.makeText(getApplicationContext(), "Cannot make call",
Toast.LENGTH_SHORT).show();
}
}
});
Just replace "#" with Uri.encode("#") or "%23". But I will not recommend this, as this can cause some security issues.

Open Epub from uri ActivityNotFoundException Error Android

Im open a epub file when I press a button, but when my android donĀ“t have any epub reader, show an toast saying please install epub reader, but my code not works, and stopp my app saying the app stop unexpectedly.
Button leer = (Button) findViewById(R.id.Btnleer);
leer.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v2) {
// TODO Auto-generated method stub
File file = new File("/sdcard/Mi Biblioteca/"+nomb+".epub");
Intent intentreadf = new Intent(Intent.ACTION_VIEW);
intentreadf.setDataAndType(Uri.fromFile(file),"application/epub+zip");
intentreadf.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intentreadf);
try {
startActivity(intentreadf);
}
catch (ActivityNotFoundException e) {
Toast.makeText(getApplicationContext(),
"favor descargar lector epub.",
Toast.LENGTH_SHORT).show();
}
}
});
Remove the first startActivity(intentreadf); command right after intentreadf.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);. It gets called before your try-catch block, and hence throws an exception.

logOut from Facebook in Android Phonegap

I have successfully setup the Facebook Plugin by Jos located (https://github.com/jos3000/phonegap-plugins/tree/master/Android/Facebook) - but I can't seem to figure out a way to log the user out. Sure I could tell them to delete the App access on the website then try to login again and click on "Not you?" but I would really rather have a JS Function that does it for me.
Can anyone help provide some guidance on how to do this? I've looked through the files and it looks like there is a way to do it in the facebook.java but I just need to hack something together to connect it to webview. I'm not capable of doing so :) can anyone please help?
This solution is to disable the single sign on feature in the Facebook plugin
in FaceBook.java file
replace DEFAULT_AUTH_ACTIVITY_CODE in the Authorize method [2 overloads] by FORCE_DIALOG_AUTH
in FacebookAuth.Java file
append this to execute method [in the switch case section]
else if (action.equals("performLogout")){
this.performLogout(first);}
//Add this method to FacebookAuth.java class
public void performLogout(final String appid) {
Log.d("PhoneGapLog", "LOGOUT");
final FacebookAuth fba = this;
Runnable runnable = new Runnable() {
public void run() {
fba.mFb = new Facebook(appid);
fba.mFb.setPlugin(fba);
try {
fba.mFb.logout((Activity) fba.ctx);
fba.success(new PluginResult(PluginResult.Status.OK, ""), fba.callback);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
};
};
this.ctx.runOnUiThread(runnable);
}
//in facebook.js file add the following section
Facebook.prototype.Logout = function(app_id,callback){
PhoneGap.exec(callback,null, "FacebookAuth", "performLogout", [app_id]); };
// in your page add the following code
function LogoutClick() //on logout click
{
appId = "123" ; //your app Id
window.plugins.facebook.Logout(appId,CompleteLogout);
}
function CompleteLogout() //call back function
{
//do some logic for callback
}
//Enjoy..!!

Categories

Resources