Нажмите window + R (Run window Open)
и в окне окна запуска "services.msc"
, а новые службы откроют службу поиска SQL SERVER(SQLEXPRESS)
и повторите попытку, это работает для меня. Надеюсь, что это тоже работает для вас.
Ответ Paresh Mayani в основном верен. Просто используйте Broadcast Intent, чтобы система и все другие приложения выбирали, каким образом контент будет использоваться совместно.
Чтобы поделиться текстом, используйте следующий код:
String message = "Text I want to share.";
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("text/plain");
share.putExtra(Intent.EXTRA_TEXT, message);
startActivity(Intent.createChooser(share, "Title of the dialog the system will open"));
String message = "This is testing."
Intent shareText = new Intent(Intent.ACTION_SEND);
shareText .setType("text/plain");
shareText .putExtra(Intent.EXTRA_TEXT, message);
startActivity(Intent.createChooser(shareText , "Title of the dialog the system will open"));
Это позволит вам поделиться своим приложением с каким-либо приложением и т. д.:
try
{ Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_SUBJECT, "My application name");
String sAux = "\nLet me recommend you this application\n\n";
sAux = sAux + "https://play.google.com/store/apps/details?id=Orion.Soft \n\n";
i.putExtra(Intent.EXTRA_TEXT, sAux);
startActivity(Intent.createChooser(i, "choose one"));
да, вы можете ... вам просто нужно знать точное имя пакета приложения:
И вы может создать такое намерение
Intent intent = context.getPackageManager().getLaunchIntentForPackage(application);
if (intent != null) {
// The application exists
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setPackage(application);
shareIntent.putExtra(android.content.Intent.EXTRA_TITLE, title);
shareIntent.putExtra(Intent.EXTRA_TEXT, description);
// Start the specific social application
context.startActivity(shareIntent);
} else {
// The application does not exist
// Open GooglePlay or use the default system picker
}
Я думаю, что следующий код поможет ....
public void btnShareClick(View v) {
// shareBtnFlag = 1;
Dialog d = new Dialog(DrawAppActivity.this);
d.requestWindowFeature(d.getWindow().FEATURE_NO_TITLE);
d.setCancelable(true);
d.setContentView(R.layout.sharing);
final Button btnFacebook = (Button) d.findViewById(R.id.btnFacebook);
final Button btnEmail = (Button) d.findViewById(R.id.btnEmail);
btnEmail.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
if (!btnEmail.isSelected()) {
btnEmail.setSelected(true);
} else {
btnEmail.setSelected(false);
}
saveBtnFlag = 1;
// Check if email id is available-------------
AccountManager manager = AccountManager
.get(DrawAppActivity.this);
Account[] accounts = manager.getAccountsByType("com.google");
Account account = CommonFunctions.getAccount(manager);
if (account.name != null) {
emailSendingTask eTask = new emailSendingTask();
eTask.execute();
if (CommonFunctions.createDirIfNotExists(getResources()
.getString(R.string.path)))
{
tempImageSaving(
getResources().getString(R.string.path),
getCurrentImage());
}
Intent sendIntent;
sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("application/octet-stream");
sendIntent.setType("image/jpeg");
sendIntent.putExtra(Intent.EXTRA_EMAIL,
new String[] { account.name });
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Drawing App");
sendIntent.putExtra(Intent.EXTRA_TEXT, "Check This Image");
sendIntent.putExtra(Intent.EXTRA_STREAM,
Uri.parse("file://" + tempPath.getPath()));
List<ResolveInfo> list = getPackageManager()
.queryIntentActivities(sendIntent,
PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() != 0) {
startActivity(Intent.createChooser(sendIntent,
"Send Email Using:"));
}
else {
AlertDialog.Builder confirm = new AlertDialog.Builder(
DrawAppActivity.this);
confirm.setTitle(R.string.app_name);
confirm.setMessage("No Email Sending App Available");
confirm.setPositiveButton("Set Account",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
dialog.dismiss();
}
});
confirm.show();
}
} else {
AlertDialog.Builder confirm = new AlertDialog.Builder(
DrawAppActivity.this);
confirm.setTitle(R.string.app_name);
confirm.setMessage("No Email Account Available!");
confirm.setPositiveButton("Set Account",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
Intent i = new Intent(
Settings.ACTION_SYNC_SETTINGS);
startActivity(i);
dialog.dismiss();
}
});
confirm.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
dialog.dismiss();
}
});
confirm.show();
}
}
});
btnFacebook.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
if (!btnFacebook.isSelected()) {
btnFacebook.setSelected(true);
} else {
btnFacebook.setSelected(false);
}
saveBtnFlag = 1;
// if (connection.isInternetOn()) {
if (android.os.Environment.getExternalStorageState().equals(
android.os.Environment.MEDIA_MOUNTED)) {
getCurrentImage();
Intent i = new Intent(DrawAppActivity.this,
FaceBookAuthentication.class);
i.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(i);
}
else {
ShowAlertMessage.showDialog(DrawAppActivity.this,
R.string.app_name, R.string.Sd_card,
R.string.button_retry);
}
}
});
d.show();
}
public void tempImageSaving(String tmpPath, byte[] image) {
Random rand = new Random();
tempfile = new File(Environment.getExternalStorageDirectory(), tmpPath);
if (!tempfile.exists()) {
tempfile.mkdirs();
}
tempPath = new File(tempfile.getPath(), "DrawApp" + rand.nextInt()
+ ".jpg");
try {
FileOutputStream fos1 = new FileOutputStream(tempPath.getPath());
fos1.write(image);
fos1.flush();
fos1.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
sendBroadcast(new Intent(
Intent.ACTION_MEDIA_MOUNTED,
Uri.parse("file://" + Environment.getExternalStorageDirectory())));
}
public byte[] getCurrentImage() {
Bitmap b = drawingSurface.getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
b.compress(Bitmap.CompressFormat.PNG, 100, stream);
byteArray = stream.toByteArray();
return byteArray;
}
private class emailSendingTask extends AsyncTask<String, Void, String> {
@Override
protected void onPreExecute() {
progressDialog = new ProgressDialog(DrawAppActivity.this);
progressDialog.setTitle(R.string.app_name);
progressDialog.setMessage("Saving..Please Wait..");
// progressDialog.setIcon(R.drawable.icon);
progressDialog.show();
}
@Override
protected String doInBackground(String... urls) {
String response = "";
try {
if (android.os.Environment.getExternalStorageState().equals(
android.os.Environment.MEDIA_MOUNTED)) {
response = "Yes";
} else {
ShowAlertMessage.showDialog(DrawAppActivity.this,
R.string.app_name, R.string.Sd_card,
R.string.button_retry);
}
} catch (Exception e) {
e.printStackTrace();
}
return response;
}
@Override
protected void onPostExecute(String result) {
if (result.contains("Yes")) {
getCurrentImage();
}
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
Uri.parse("file://"
+ Environment.getExternalStorageDirectory())));
progressDialog.cancel();
}
}
private class ImageSavingTask extends AsyncTask<String, Void, String> {
@Override
protected void onPreExecute() {
progressDialog = new ProgressDialog(DrawAppActivity.this);
progressDialog.setTitle(R.string.app_name);
progressDialog.setMessage("Saving..Please Wait..");
// progressDialog.setIcon(R.drawable.icon);
progressDialog.show();
}
@Override
protected String doInBackground(String... urls) {
String response = "";
try {
if (android.os.Environment.getExternalStorageState().equals(
android.os.Environment.MEDIA_MOUNTED)) {
response = "Yes";
} else {
ShowAlertMessage.showDialog(DrawAppActivity.this,
R.string.app_name, R.string.Sd_card,
R.string.button_retry);
}
} catch (Exception e) {
e.printStackTrace();
}
return response;
}
@Override
protected void onPostExecute(String result) {
if (result.contains("Yes")) {
getCurrentImage();
if (CommonFunctions.createDirIfNotExists(getResources()
.getString(R.string.path)))
{
saveImageInSdCard(getResources().getString(R.string.path),
getCurrentImage());
}
}
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
Uri.parse("file://"
+ Environment.getExternalStorageDirectory())));
progressDialog.cancel();
}
}
Для приложения facebook используйте facebook SDK
Я думаю, вы хотите предоставить кнопку Share, нажав на которую должен присутствовать подходящий вариант для СМИ / веб-сайта, чтобы поделиться им. В Android вам необходимо создать createChooser
для этого же.
Обмен текстом:
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is the text that will be shared.");
startActivity(Intent.createChooser(sharingIntent,"Share using"));
Обмен двоичными объектами (изображения, видео и т. Д.)
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse(path);
sharingIntent.setType("image/png");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));
FYI, код выше из Общий доступ к содержимому в Android с использованием ACTION_SEND Intent
ACTION_SEND
предоставит вам только варианты отправки с помощью GMail, YahooMail ... и т. д. (Любое приложение, установленное на вашем телефоне, которое может выполнять ACTION_SEND
). Если вы хотите поделиться на Facebook или Twitter, вам нужно будет поместить пользовательские кнопки для каждого из них и использовать свой собственный SDK, например Facebook SDK или Twitter4J .
ACTION_SEND будет работать корректно для всех, и он берет тело текста на стену в твиттере, G mail .. но он не работает на странице Face Book ... Его известная ошибка в Android android SDK .. но все же они не фиксировали его
ACTION_SEND
хорошо работает для Facebook и Facebook Messenger. Но стоит подготовить соответствующие мета-теги OpenGraph на сервере , если вы хотите, чтобы сообщение сообщения отображало значащее уменьшенное изображение и описание. См. stackoverflow.com/questions/1138460/… .
– Alex Cohn
24 June 2015 в 08:40
Используйте этот параметр
Facebook - "com.facebook.katana"
Twitter - "com.twitter.android"
Instagram - "com.instagram.android"
Pinterest - "com.pinterest"
SharingToSocialMedia("com.facebook.katana")
public void SharingToSocialMedia(String application) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_STREAM, bmpUri);
boolean installed = checkAppInstall(application);
if (installed) {
intent.setPackage(application);
startActivity(intent);
} else {
Toast.makeText(getApplicationContext(),
"Installed application first", Toast.LENGTH_LONG).show();
}
}
private boolean checkAppInstall(String uri) {
PackageManager pm = getPackageManager();
try {
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
return true;
} catch (PackageManager.NameNotFoundException e) {
}
return false;
}
appInstalledOrNot(application)
is stackoverflow.com/a/11392276/1293313
– MilapTank
31 March 2016 в 12:53
appInstalledOrNot(application)
его средства для проверки приложения желания не устанавливаются на ваше устройство или нет ...
– Arslan Maqbool
16 November 2017 в 14:23