• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

The Galaxy s7

Everything is good but only one thing it suffers

Is when it was updated to Android Oreo, Oreo has a issue with draining battery a little bit faster and watching 4K videos on YouTube does lag a bit

It has expandable storage up to 64GB, 3.5mm headphone jack, 4GB of DDR3 RAM, wireless charging

Get value and compare it to file content same value

Hi ! I want to create a small program with android studio that can take a value entered by a user and compare that value to another identical value that exists in a file stored in the internal memory of the phone. If this value exists in the file, select the file in question and send it to a server... Could someone help me with that ?

I'll post some code I use in my own apps to get you started. The rest you can figure out on your own with a little googling and asking around.

The BufferedReader is perfect for this situation. You can use it to get the contents of a file on your phone and compare the contents to a string which is what it seems you're trying to do.

Method to read file contents - getFileContent():
Java:
private static String getFileContent(String file) {
  String content = "";
  try (BufferedReader br = new BufferedReader(new FileReader(file))) {
    StringBuilder sb = new StringBuilder();
    String line = br.readLine();
    while (line != null) {
      sb.append(line);
      line = br.readLine();
      if (line != null) {
        sb.append(System.lineSeparator());
      }
    }
    content = sb.toString();
  } catch (IOException e) {
    e.printStackTrace();
  }
  return content;
}

Using the method getFileContent():
Java:
if (getFileContent("/path/to/filename").contains("string-to-check")) {
  // run your code here for a match
} else {
  // run code here for no match
}

Good luck ;)

Double end cord

FYI the JBL Flip 4 speaker uses micro-USB for power and charging. Power-banks usually have standard sized USB power outputs, it may have micro-USB and/or type-C USB as well, all depending on the particular one you've got there. For a speaker from a power-bank, you can just use any phone USB cord, provided it has the appropriate connectors.

Apps Surface View Player

Hey guys, i started to make my own tv app cause wanted to add my idea's..lol

so i got lots of it going but stuck on this surfaceview issue

1.when i click a link the screen gow's black then loads the video?

i think i found it. by adding:
Java:
@override
public void surfaceDestroyed(SurfaceHolder arg0) {
    if (mediaPlayer != null) {
        mCurrentVideoPosition = mediaPlayer.getCurrentPosition();
        mediaPlayer.release();
        mediaPlayer = null;
    }
}

2.when i press back to go back to the main screen ,seems like it created layers everytime i click a link...
is there a way to destroy the previous and make a new one every click?to avoid that..


Java:
@Override
    public void surfaceCreated(SurfaceHolder arg0) {
        if(mStream_id != null){
            String contentUri = Url + "live/" + username + "/" + password + "/" + mStream_id + ".ts";
            try {
                mediaPlayer = new MediaPlayer();
                mediaPlayer.setDisplay(vidHolder);
                mediaPlayer.setDataSource(contentUri);
                mediaPlayer.prepare();
                mediaPlayer.setOnPreparedListener(this);
                mediaPlayer.setOnBufferingUpdateListener(this);
                mediaPlayer.setOnCompletionListener(this);
                mediaPlayer.setScreenOnWhilePlaying(true);
                mediaPlayer.setOnVideoSizeChangedListener(this);
                mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
            } catch (IllegalArgumentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (SecurityException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalStateException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }
    }

Apps Scheduled Runs

I'm trying to schedule the running of a function in the MainActivity thread. I've tried both an AlarmManager and a Handler. They both look like they're going through, but nothing ever runs at the time it's supposed to. Not sure what I'm doing wrong here. Any help would be greatly appreciated. Admittedly, I'm a bit noobish, though this is my second app (both very basic).

The relevant sections of the code for Handler:
Java:
    public Runnable r;
    public Handler TSH = new Handler();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
...
        r = new Runnable() {
            @Override
            public void run() {         Log.d("Tag","Hi Again");
                RefreshList();}
        };
Calendar c1 = Calendar.getInstance();
c1.add(Calendar.MINUTE,1);
TSH.postAtTime(r, c1.getTimeInMillis());

The relevant sections of the code for AlarmManager:
Java:
public class TrainCheckerAlarm  extends BroadcastReceiver {
    public MainActivity ma;

    public void GetMA(MainActivity m) {ma = m;}

    @Override
    public void onReceive(Context context, Intent intent)
    {
        ma.RefreshList();
    }
    public void setAlarm(Context context, Calendar cal)
    {
        AlarmManager am =( AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
        Intent i = new Intent(context, TrainCheckerAlarm.class);
        PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0);
        am.set(AlarmManager.ELAPSED_REALTIME, cal.getTimeInMillis(), pi);
    }
}
Then in MainActivity, there's a:
public TrainCheckerAlarm TCA = new TrainCheckerAlarm();
TCA.GetMA(this);
TCA.setAlarm(this,c1);

App Inventor How to play video fullscreen with landscape in Android WebView?

Person I have an application that I have a html5 player I have also a code that makes my webview accept that this html 5 enables the full screen player option. It even needs to be with screen rotation enabled to be able to see landscape but I want it to be landscape when I click the full screen option. How do I do it?

code down:
class Browser_home extends WebViewClient {

Browser_home() {
mInterstitialAd.show ();
}

@override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
mInterstitialAd.show ();
super.onPageStarted(view, url, favicon);

}

@override
public void onPageFinished(WebView view, String url) {
mInterstitialAd.show ();
setTitle(view.getTitle());
super.onPageFinished(view, url);



}
}





private class MyChrome extends WebChromeClient {

private View mCustomView;
private WebChromeClient.CustomViewCallback mCustomViewCallback;
protected FrameLayout mFullscreenContainer;
private int mOriginalOrientation;
private int mOriginalSystemUiVisibility;


MyChrome() {mInterstitialAd.show ();}

public Bitmap getDefaultVideoPoster()
{
if (mCustomView == null) {
mInterstitialAd.show ();
return null;

}
mInterstitialAd.show ();
return BitmapFactory.decodeResource(getApplicationContext().getResources(), 2130837573);
}

public void onHideCustomView()
{
mInterstitialAd.show ();
((FrameLayout)getWindow().getDecorView()).removeView(this.mCustomView);
this.mCustomView = null;
getWindow().getDecorView().setSystemUiVisibility(this.mOriginalSystemUiVisibility);
setRequestedOrientation(this.mOriginalOrientation);
this.mCustomViewCallback.onCustomViewHidden();
this.mCustomViewCallback = null;

}

public void onShowCustomView(View paramView, WebChromeClient.CustomViewCallback paramCustomViewCallback)
{
if (this.mCustomView != null)
{
mInterstitialAd.show ();
onHideCustomView();

return;
}
mInterstitialAd.show ();
this.mCustomView = paramView;
this.mOriginalSystemUiVisibility = getWindow().getDecorView().getSystemUiVisibility();
this.mOriginalOrientation = getRequestedOrientation();
this.mCustomViewCallback = paramCustomViewCallback;
((FrameLayout)getWindow().getDecorView()).addView(this.mCustomView, new FrameLayout.LayoutParams(-1, -1));
getWindow().getDecorView().setSystemUiVisibility(3846);

}

}

Help Weather Bug Alert Notification

I really like weather bug, but can't seem to get the weather alert notifications to work. I've even got a cool thunder clap picked out for the sound.

I've got everything set in weather bug, I get the temp notification, and the alert notification icon will show up, but no sound.

Anyone have this issue?
Yes I do I have tryed everything it's. Told me to do. Help

Help Headphone doesn't work

It's very rare that "X doesn't work" is sufficient information to let someone else solve the problem. So a couple of things to check:

Do the headphones work with another device?
- if not, they're probably broken.

Do other headphones work with this phone?
- if not, check carefully that there's no dirt in the socket, and make sure you are able to push them in all of the way. A badly-designed case may interfere with plugging in too.

If the answer to both is yes, definitely check they plug in correctly. Then give us as much information as you can.

If the answer to both is no, and you are sure that you can plug them in properly, then the problem is the phone, but we need to work out whether it's hardware or software.

Oh, and I've been assuming they don't work at all. If it's only calls that don't work that would be important to know as well.

Filter

Back
Top Bottom