Ver mensagens sem resposta | Ver tópicos ativos Hoje é 23 Out 2017, 19:50



Responder Tópico  [ 3 Mensagens ] 
 Opção Play externo! 
Autor Mensagem
What is Android?
What is Android?

Data de registro: 11 Out 2017, 00:41
Mensagens: 3
Mensagem Opção Play externo!
Olá amigo tudo bem!

Amigo tenho um app que roda vídeo em um play interno do próprio app eu queria que quando a pessoa clicar em play aparece 2 opção sendo uma de executar o vídeo no play padrão do app e a outra de escolher um play externo instalado no android do usuário para executar o video.


Obrigado.


11 Out 2017, 00:44
Perfil
Google employee
Google employee

Data de registro: 01 Jul 2013, 13:45
Mensagens: 2679
Localização: Rio de Janeiro
Mensagem Re: Opção Play externo!
Testa isso aí:


    Intent i = new Intent(Intent.ACTION_SEND);
   
    i.putExtra(Intent.EXTRA_STREAM, Uri.parse(caminhoDoVideo));
    i.setType("video/*");
   
    startActivity(Intent.createChooser(i, "Abrir com"));
 

_________________
Quando seu problema for resolvido, clique na opção Editar no lado superior direito da sua primeira mensagem e coloque [Resolvido] no título.
Se resolveu o problema sozinh@, não esqueça de postar a solução, ela ajuda usuários em buscas no fórum.
Use os marcadores java e xml quando for postar.

Aprenda Java com esta apostila.


17 Out 2017, 03:40
Perfil WWW
What is Android?
What is Android?

Data de registro: 11 Out 2017, 00:41
Mensagens: 3
Mensagem Re: Opção Play externo!
Obrigado por sua resposta amigo! /xx


Meu projeto não abre por url.

De uma olhada no meu MainActivity.java.


Obrigado.


public class MainActivity extends AppCompatActivity {

private DrawerLayout drawerLayout;
private FragmentManager fragmentManager;
MyApplication MyApp;
final int MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 102;
String[] PERMISSIONS = {Manifest.permission.WRITE_EXTERNAL_STORAGE};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
fragmentManager = getSupportFragmentManager();
MyApp = MyApplication.getInstance();
NavigationView navigationView = (NavigationView) findViewById(R.id.navigation_view);
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

AdView mAdView = (AdView) findViewById(R.id.adView);
mAdView.loadAd(new AdRequest.Builder().build());

HomeFragment homeFragment = new HomeFragment();
fragmentManager.beginTransaction().replace(R.id.Container, homeFragment).commit();

navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {

drawerLayout.closeDrawers();
switch (menuItem.getItemId()) {
case R.id.menu_go_home:
toolbar.setTitle(getString(R.string.menu_home));
HomeFragment homeFragment = new HomeFragment();
fragmentManager.beginTransaction().replace(R.id.Container, homeFragment).commit();
return true;
case R.id.menu_go_category:
toolbar.setTitle(getString(R.string.menu_category));
CategoryFragment currentCategory = new CategoryFragment();
fragmentManager.beginTransaction().replace(R.id.Container, currentCategory).commit();
return true;
case R.id.menu_go_latest:
toolbar.setTitle(getString(R.string.menu_latest));
LatestFragment latestFragment = new LatestFragment();
fragmentManager.beginTransaction().replace(R.id.Container, latestFragment).commit();
return true;
case R.id.menu_go_favourite:
toolbar.setTitle(getString(R.string.menu_favourite));
FavouriteFragment favouriteFragment = new FavouriteFragment();
fragmentManager.beginTransaction().replace(R.id.Container, favouriteFragment).commit();
return true;
case R.id.menu_go_profile:
Intent profile = new Intent(MainActivity.this, ProfileActivity.class);
startActivity(profile);
return true;
case R.id.menu_go_about:
Intent about = new Intent(MainActivity.this, AboutUsActivity.class);
startActivity(about);
return true;
case R.id.menu_go_rate:
RateApp();
return true;
case R.id.menu_go_share:
ShareApp();
return true;
case R.id.menu_go_logout:
Logout();
return true;
case R.id.menu_go_privacy:
Intent privacy = new Intent(MainActivity.this, PrivacyActivity.class);
startActivity(privacy);
return true;
default:
return true;
}
}
});

ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close) {
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
}

@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
}
};
drawerLayout.setDrawerListener(actionBarDrawerToggle);
actionBarDrawerToggle.syncState();
if (!MyApp.getIsLogin()) {
navigationView.getMenu().findItem(R.id.menu_go_profile).setVisible(false);
navigationView.getMenu().findItem(R.id.menu_go_logout).setVisible(false);
}

if(!hasPermissions(this, PERMISSIONS)){
ActivityCompat.requestPermissions(this, PERMISSIONS, MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_main, menu);
final MenuItem searchMenuItem = menu.findItem(R.id.search);
final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);

searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {

@Override
public void onFocusChange(View v, boolean hasFocus) {
// TODO Auto-generated method stub
if (!hasFocus) {
MenuItemCompat.collapseActionView(searchMenuItem);
searchView.setQuery("", false);
}
}
});

searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

@Override
public boolean onQueryTextSubmit(String arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent(MainActivity.this, SearchActivity.class);
intent.putExtra("search", arg0);
startActivity(intent);
searchView.clearFocus();
return false;
}

@Override
public boolean onQueryTextChange(String arg0) {
// TODO Auto-generated method stub
return false;
}
});
return super.onCreateOptionsMenu(menu);
}

private void Logout() {
new AlertDialog.Builder(MainActivity.this)
.setTitle(getString(R.string.menu_logout))
.setMessage(getString(R.string.logout_msg))
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
MyApp.saveIsLogin(false);
Intent intent = new Intent(getApplicationContext(), IntroActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
}
})
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// do nothing
}
})
.setIcon(R.drawable.ic_logout)
.show();
}

private void ShareApp() {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.share_msg) + getPackageName());
sendIntent.setType("text/plain");
startActivity(sendIntent);
}

private void RateApp() {
final String appName = getPackageName();//your application package name i.e play store application url
try {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id="
+ appName)));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(
Intent.ACTION_VIEW,
Uri.parse("http://play.google.com/store/apps/details?id="
+ appName)));
}
}

@Override
public void onBackPressed() {
ExitApp();
//super.onBackPressed();
}

private void ExitApp() {
new AlertDialog.Builder(MainActivity.this)
.setTitle(getString(R.string.app_name))
.setMessage(getString(R.string.exit_msg))
.setIcon(R.mipmap.ic_launcher)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
finish();
}
})
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// do nothing
}
})
.show();
}

public static boolean hasPermissions(Context context, String... permissions) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && context != null && permissions != null) {
for (String permission : permissions) {
if (ActivityCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED) {
return false;
}
}
}
return true;
}

@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {

boolean canUseExternalStorage = false;

switch (requestCode) {
case MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE: {
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
canUseExternalStorage = true;
}
if (!canUseExternalStorage) {
Toast.makeText(MainActivity.this, "Você não pode ver imagens sem permissão solicitada", Toast.LENGTH_SHORT).show();
} else {
// user now provided permission
// perform function for what you want to achieve
Log.i("Permission", "granted");
}
}
}
}
}


17 Out 2017, 08:27
Perfil
Mostrar mensagens anteriores:  Organizar por  
Responder Tópico   [ 3 Mensagens ] 

Quem está online

Usuários vendo este fórum: adelar, ademir.carvalhojr, adenilsonsena, adolfo, alansousa, alexcost2002, alsimoes, am2net, Anakin Skywalker, andrelom, andreluzz, apoena, b7web, Bass, Berbert, bravus, brazucx, brian15, brpiassa, canaville, cariabs8, Cassius, cfranca, Chefe Nass, Christiane, claudioalfonso, Clone Trooper, comolatti, Costa, cyzko, czambroni, danielbfranco, dariosena, Darth Maul, diogeneskelsen, Douglas Siviotti, Eduardo, eluttner, epsilva, eusobacana, Everton Moreira, Faroli, fcoroa, Felipe, fraga, free_w3000, gabrielatme, geco, genildof, Geovanne Duarte, Gnomo, Guilherme Cobain, gustavobarbosa, gutodias, humberto, Ielo8, itsN, Jaison, Jar Jar Binks, joaquimfoto, João Miguel Aguiar, juliaojunior, jzaires, lanlan, leofernandesmo, Liviosousa, Lúcio Zanette, m4v0, maiconjunches, mapis, marcelosv, marcosrogel, masf_33, maurofjr, mrangel, mrkensley, MSN NewsBlogs, neimarguerra, nq6, obitow, pchofard, piagg, PicsearchDroid, Rainha Amidala/Padmé, regeriob2br, rfrafael, rlecheta, Roberto, rogerio, rogeriopgomes, romuloff, sephct, sergio, siker C3PO, Snappy [Bot], suissa, talves, tassiovirginio, Telekom [Bot], Thelemita, thosjanas, tiasousa, tricx16, unnamedd, vicfalmac, VIEIRIX, vilmartr, viniciusluiz, W3 [Sitesearch], washington, Wds, wesley.messias, woyzeck, xa:=zin, Yoshihury, yuri82, zeantonio e 8 visitantes


Você não pode criar novos tópicos neste fórum
Você não pode responder tópicos neste fórum
Você não pode editar suas mensagens neste fórum
Você não pode excluir suas mensagens neste fórum
Você não pode enviar anexos neste fórum

Procurar por:

© 2007 - 2016 Portal Android - Comunidade de Desenvolvedores Android

Estamos no Linkedin    Siga-nos no twitter


Powered by phpBB - Hospedado por Bemobi