Android - setting up guidelines in the camera [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I was wondering if there was a way to add a vertical and horizontal yellow lines in the middle of the width and length respectively on the camera, so that the user has a rough guideline when making the photo. I can post code if needed. Thanks in advance.

This code may help your:
final Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
dialog.setContentView(R.layout.guideline);
dialog.setCanceledOnTouchOutside(true);
//for dismissing anywhere you touch
View masterView = dialog.findViewById(R.id.guidelineView);
masterView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
dialog.dismiss();
}
});
dialog.show();

Related

Correct method to implement onCreate in android [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
My app crashes. I look throught most are using this approach public class MainActivity extends
where is the errors in this short code
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main5);
radioGroup=findViewById(R.id.radioGroup);
textView=findViewById(R.id.text_view);
Button ok=findViewById(R.id.ok);
ok.setOnClickListener(new view.onClicklisenn){
public void onClick(view view){
int radioId=radioGroup.getCheckedRadioButtonId();
radioButton=findViewById(radioId);
textView.setText("choise"+radioButton.getText());
}
}
}
Use this in your code if you have initialised all variables correctly
ok.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
int radioId=radioGroup.getCheckedRadioButtonId();
radioButton=findViewById(radioId);
textView.setText("choise"+radioButton.getText());
}
});

Loading View while ListView Is Fulling [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I was trying to make a code that while filling a ListView there is a Loading View.
An example?
Thank you very much
This is exactly what I wanted when I am creating my music player app. Here is how I showed another screen while loading list view using AsyncTask (runs in background).
1) Create an activity (launcher) - LoadActivity.
2) Load list view contents using an AsyncTask while showing LoadActivity.
3) Open your MainActivity after loading is complete and close LoadActivity.
In an AsyncTask,
onPreExecute - Before background task.
doInBackground - background task.
onPostExecute - After background task.
private class MyTask extends AsyncTask<Params, Progress, Result> {
protected void onPreExecute() {
// Before your task
}
protected Long doInBackground(Params... params) {
// Your Task
return result;
}
protected void onPostExecute(Result result) {
// After your task
startActivity(new Intent(LoadActivity.this, MainActivity.class));
finish();
}
}
Then, in your onCreate() of LoadActivity.java,
new MyTask().execute(Params... params);
For more on AsyncTask, refer the documentation.

How can I change ImageButton through another activity? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
How can I change ImageButton through another activity?
example:
I have imageButton in MainActivity.class and when I click on button in another activity changes ImageButton in the MainActivity.class
Thanks
You can implement a Local Broadcast Receiver in the Activity from where you can access the ImageButton. This receiver will be capable of hearing for a message and do something that you specify in response.
So, when you want to change the ImageButton you can send a message from the other Activity that will be received by the first one and will change the ImageButton. This message will be in an Intent form and can contain many extras.
EDIT
In your Activity #1 (The one who controls the ImageButton)
public void onCreate(Bundle savedInstanceState){
...
LocalBroadcastManager.getInstance(this).registerReceiver(mLocalBroadcastReceiver, new IntentFilter("broadcastName"));
}
private BroadcastReceiver mLocalBroadcastReceiver = new BroadcastReceiver() {
#Override
public void onReceive(Context context, Intent intent) {
//MODIFY YOUR IMAGE BUTTON HERE
}
};
In your Activity #2 (The broadcast sender)
Call sendLocalBroadcast() in any part of this Activity when you want to send the message to update the ImageButton. You can add many parameters as you want, of course.
private void sendLocalBroadcast() {
Intent intent = new Intent("broadcastName");
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent);
}

How can we put more than one activity in Android [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I want to put more than one activity in my main.java file but I don't know how to as I'm a newbie. I have inserted activity one but now I want to put activity two but unable to. Can you help me with it, the code until now on my main.java is:
public class Main extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstaceState) {
super.onCreate(savedInstaceState);
setContentView(R.layout.main);
TextView b = (TextView) findViewById(R.id.text1);
b.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
startActivity(new Intent(Main.this, One.class));
}
});
}
I have already created another activity files named Two.class and two.xml. How will the code be for next activities?
If you want two activity in a single calss use Fragments.
Fragments are mini activity in Android. They combine two or more than two activity in a single activity class
see following link for more detail
http://developer.android.com/guide/components/fragments.html
Intent intent = new Intent(getApplicationContext(),SecondActivity.class);
startActivity(intent);
I think it will help you

How to change first button's value by pressing another one [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
What I am seeking is to have button that has a x value and after pressing another button to change the value of the first. e.x first button value is, when pressed to open flashlight constantly, then I press the second button and now first's value button has changed, when pressed flashlight blinks!
Thanks in advance
private void turnOnFlash() {
if (!isFlashOn) {
if (camera == null || params == null) {
return;
}
// play sound
// playSound();
params = camera.getParameters();
params.setFlashMode(Parameters.FLASH_MODE_TORCH);
camera.setParameters(params);
camera.startPreview();
isFlashOn = true;
// changing button/switch image
toggleButtonImage();
}
Change.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (isFlashOn) {
// i want it to start blinking
} else {
//wait till opens to start blinking
}
}
}
}
and on clicking again button change, everything to return to normal.

Categories

Resources