Boa tarde galera, de ante mão ja agradeço quem puder me ajudar..
estou montando um app, mas sou muito iniciante no assunto.. tenho uma tela com 4 botões e cada um abre um scaner para uma determinada ação
consigo chamar o scan em cada botão sem problemas.
gostaria de saber como chamar um resultado diferente em cada botão.
segue um print do meu código.
public class MainActivity extends AppCompatActivity {
private Button btnEntrada, btnTransporte, btnDestino, btnEntrega;
private String HOST = "http://192.168.0.18/transportadora/aux/";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnEntrada = (Button) findViewById(R.id.btnEntrada);
Activity activity = this;
Activity finalActivity = activity;
btnEntrada.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
IntentIntegrator integrator = new IntentIntegrator(finalActivity);
integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE);
integrator.setPrompt("Scan LRCODE");
integrator.setCameraId(0);
integrator.initiateScan();
}
});
setContentView(R.layout.activity_main);
btnTransporte = (Button) findViewById(R.id.btnTransporte);
activity = this;
Activity finalActivity1 = activity;
btnTransporte.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
IntentIntegrator integrator = new IntentIntegrator(finalActivity1);
integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE);
integrator.setPrompt("Scan LRCODE");
integrator.setCameraId(0);
integrator.initiateScan();
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
IntentResult result = IntentIntegrator.parseActivityResult(requestCode,resultCode,data);
if (result != null){
if (result.getContents() != null){
String URL = HOST + "entrada.php";
String code = result.getContents();
Ion.with(MainActivity.this)
.load(URL)
.setBodyParameter("code", code)
.asJsonObject()
.setCallback(new FutureCallback<JsonObject>() {
@Override
public void onCompleted(Exception e, JsonObject result) {
try {
Toast.makeText(MainActivity.this, result.get("MSG").getAsString(), Toast.LENGTH_LONG).show();
} catch (Exception erro){
Toast.makeText(MainActivity.this, "ERRO: " + erro, Toast.LENGTH_LONG).show();
}
}
});
} else {
alert("SCAN Cancelada");
}
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
como eu faço pra chamar o método onActivityResult pra cada botão na mesma activity
Boa noite! gente, eu estou tentando colocar alguma forma de pagamentos no meu app, no caso para que o usuario possa adicionar credito ao mesmo, eu estou fazendo isso com a api da JUNO, porem, tambem quero adicionar PIX como forma de pagamento pois não saio do zero com a juno! alguem aqui ja usou PIX com android studio e pode me explicar como fazer? ja busquei por aulas e tutoriais e nada... Grato!
Olá.
Eu adoro ouvir música, então quero escolher o melhor aplicativo de música para o meu telefone. Alguém sabe quais aplicativos são adequados para telefones Android? spotify Techbigs, por exemplo, youtube premium em https://techbigs.com/10-best-music-players-for-android-in-2021.html
Olá !!! Eu já consegui abrir um link em java no navegador , porém eu queria que o link abrisse dentro de uma JPainel ou dentro do JFrame . Alguém sabe ???
webView.zip (928,Bytes)
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.border.BevelBorder;
import java.awt.Color;
import java.awt.Desktop;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.awt.event.ActionEvent;
public class WebView {
private JFrame frame;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
WebView window = new WebView();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public WebView() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 526, 422);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JPanel panel = new JPanel();
panel.setBorder(new BevelBorder(BevelBorder.LOWERED, Color.BLUE, Color.YELLOW, Color.BLACK, Color.RED));
panel.setBounds(0, 0, 518, 345);
frame.getContentPane().add(panel);
JButton btnNewButton = new JButton("Abrir web");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
File link = new File("C:\\Users\\Adriano\\Desktop\\Gem Remoto\\Hinários\\hinário em mi.pdf");
Desktop.getDesktop().open(link);
} catch (Exception e2) {
// TODO: handle exception
}
}
});
btnNewButton.setBounds(175, 361, 125, 23);
frame.getContentPane().add(btnNewButton);
}
}