When trying to set writing access in the scope I receive the application need permission
webView.loadUrl("https://stackoverflow.com/oauth/dialog?client_id=19361&redirect_uri=https://stackexchange.com/oauth/login_success&scope=no_expiry,private_info,read_inbox,write_access");
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient(){
#Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
if(url.contains("https://stackexchange.com/oauth/login_success#access_token=")){
String code=url.replace("https://stackexchange.com/oauth/login_success#access_token=","");
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.putExtra("accessToken",code);
startActivity(intent);
}
System.out.println(url);
super.onPageStarted(view, url, favicon);
}
});
You need to create any post on stackapps and set his url into stackapps post field
In order to get an access token with the write_access scope, you need a Stack Apps post.
After registering your application on StackApps and obtaining an API key and a client id, in the "Stack Apps Post" field you should enter the link to a question you have asked.
If you have already registered your app, go to "Manage your applications", select the respective application, scroll to the bottom, click "Edit this app", then enter your question link in the "Stack Apps Post" field. Then, submit your changes.
See My app has to be published first? But it's still under development.
Related
I have added a share app button and link to my app made in android studio but I'm not sure if this is the way it should work as I have checked other apps' share options and they tend to give the user an option on where exactly they'd like to share their application, while my link sends the user straight to the app page. I found this method on another thread made on this website but I'm not sure if it works properly as I haven't published my app yet. Can someone verify if this is the most popular method to share apps and if not can someone redirect me to where I can find the best solution for a share app option.
segment of my MainActivity.java code regarding the share method:
#Override
public boolean onNavigationItemSelected(#NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.nav_share:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=com.mydomain.tapp"));
startActivity(intent);
break;
}
drawerLayout.closeDrawer(GravityCompat.START);
return true;
}
You are using the wrong Intent Action for your requirement. Your requirement is to share your app's PlayStore link with another person. So, you have to use ACTION_SEND.
ACTION_VIEW is used to display the data to the user.
ACTION_SEND is used to deliver some data to someone else.
For example,
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "Sharing URL");
intent.putExtra(Intent.EXTRA_TEXT, "http://play.google.com/store/apps/details?id=com.mydomain.tapp");
startActivity(intent);
I'm having a slightly different purpose, but, I think I'm putting it wrong as no one from multiple forums is able to answer it. The original question is here: Pass URL data from AppLink to WebView
Basically, suppose I'm creating a web browser app with a splash screen and I want to accept the URL intents from other apps, receive them in my splash screen, pass them on to my WebView activity and load it there, how can I do that?
For example, if a user has my app installed, and he/she taps https://www.google.com/ as a link in some app, how can I load the URL in my app after showing my splash screen? I think, the intent receiver will be in the splash screen activity, and the WebView is in another activity. So, basically, I want to receive the URL in my splash screen activity and then, pass it on to my WebView. How to achieve this?
I think what youre trying to do is to recieve data from other apps
That way, you can recieve data in a Splash Screen Activity and then show it in a Web View Activity
You can do this through putExtra method.
You can use intents, which are messages sent between activities. In an intent you can put all sort of data, String, int, etc.
In your case, in Splash Screen(say SplashActivity), before going to next activity(say MainActivity), you need to store a String message this way :
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
intent.putExtra("message", message);
startActivity(intent);
In MainActivity, in onCreate(), you can get the String message by retrieving a Bundle (which contains all the messages sent by the calling activity) and call getString() on it :
Bundle bundle = getIntent().getExtras();
String message = bundle.getString("message");
Then you can use message variable as url.:
Hope this helps !
I am developing an Android App using WebView which loads a locally stored HTML5/JQuery Mobile app in the assets folder. The App gets content from a REST service on a domain I own. The content is a mixture of HTML content and downloadable files.
My problem lies when a user clicks on a button to download a file, a Browser window launches and the file is downloaded, which is great. However my App then loses focus and I have a blank browser on screen. I have done a bit of Googling and have read a few answers on Stack Overflow and have adapted my code to set a Download Listener, but this still loads the Browser. Please advise. My code is listed below
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView webView = (WebView)findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAllowFileAccess(true);
webView.setWebChromeClient(new WebChromeClient());
webView.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
webView.loadUrl("file:///android_asset/www/index.html");
}
Have you tried using the Android DownloadManager (please see http://developer.android.com/reference/android/app/DownloadManager.html) instead of starting a VIEW Intent? I think that you'd just need to enqueue a download from your DownloadListener.
When user taps gallery button I want user to redirect to my application's activity which will ask the user to enter password and then redirect user back to gallery ..
I want to know which permissions should i use and which broadcast should i accept .
Well If you want to lock the gallery you can do it in encrypt Decrypt way...
You can use MediaStore to access the images and then encrypt using your application and when user Again want to access that you can allow him to show by decrypting ...
Read the following link
Can I create password protected folder in Android?
You would need to replace the gallery application entirely to do what you're proposing.
When a user taps the Gallery icon, it doesn't fire a broadcast. It sends a directed intent with the action set to MAIN.
Anything that anyone tells you for how to do this is going to be wrong. You cannot do it.
The closest you could get is to use the MediaStore in your own app to access the same images that the gallery accesses.
Start a thread from your app which should periodically monitor foreground app name which in this case should be the Gallery (I cant remember the exact name But you can find it out using below logic).
Then if it is Gallery, open up your activity by blocking it.
If password success close activity & background will be the Gellery or otherwise redirect to Home.
For monitor foreground app
try {
ActivityManager activityManager = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> runningTasks = activityManager.getRunningTasks(1);
PackageManager pm = getApplicationContext().getPackageManager();
output1 = pm.getApplicationLabel(pm.getApplicationInfo(runningTasks.get(0).baseActivity.getPackageName(),PackageManager.GET_META_DATA)).toString();
String className = runningTasks.get(0).topActivity.getClassName();
if( className.contains("Gallery")) {
//better to create this object globally outside the thread.
Intent intentSettingLock = new Intent();
intentSettingLock.setClass(oContext,SettingsLockNew.class);
intentSettingLock.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
oContext.startActivity(intentSettingLock);
}
}
catch(Exception e) {
}
To redirect to home on invalid password
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
startActivity(intent);
this.finish();
You can not perform this as you described because pressing the gallery app icon from the launcher the system fires an intent with action=MAIN and category=LAUNCHER for the specific application package.
Since you cannot name your application package as the gallery package name you cant filter this intent.
I am able to intent to the youtube app to view a video easily enough, but how about getting to a profile / channel?
public void YouTube(String id) {
// Play Youtube Video
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:"+id));
mContext.startActivity(i);
}
I.. just don't know where to really begin here? Is there a specific Uri to parse? I've tried scouring the internet of course and I'm coming up dry for answers. Is it even possible in the first place?
Thanks guys!
By doing the following ,one can launch Youtube App to display channel directly
Intent intent=null;
try {
intent =new Intent(Intent.ACTION_VIEW);
intent.setPackage("com.google.android.youtube");
intent.setData(Uri.parse(url));
startActivity(intent);
} catch (ActivityNotFoundException e) {
intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
}
And in order to display channel,keep in mind to give url in format http://www.youtube.com/user/channelName
As of now, there is no specific URI scheme for channels that would trigger the YouTube application directly. The vnd.youtube scheme is defined only for the activity that plays a single video. So, you have to specify the canonical YouTube URL for the channel page, and typically let the user pass through the application chooser dialog - assuming that the device has the YouTube application installed, the dialog would display at least two entries, the second being for the browser.