人気の記事を表示させるプラグインWordPress Popular Postsが有効にしたら、wp-adminのBasic認証画面が出てきます。これは、WordPress Popular Postsの設定→TOOLS→Ajaxify widgetがEnabledにして、wp-admin/admin-ajax.phpがJavacriptからアクセスしていると考えられます。wp-admin/.htaccessを以下内容を追加して、admin-ajax.phpへのアクセスを許可しておきます。
<Files ~ "^admin\-ajax\.php$">
Satisfy Any
allow from all
</Files>
import com.soarcloud.O2O.Browser;
findButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent in = new Intent(getApplicationContext(), Browser.class);
startActivity(in);
}
});
2、遷移先のブラウザ画面 Brower.jaza
public class Browser extends Activity implements LocationListener {
private WebView webView;// Create WebView object
private Location mostRecentLocation;// Create Location object
private LocationManager locationManager;// Create LocationManager object
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.browser);
getLocation();// Get the current geocoordinates
openBrowser();// Open a browser with the Google MapView
} // end main activity method
/** Called when Activity Resumes **/
protected void onResume() {
super.onResume();
getLocation();
} // end onResume method
/** Called when Activity is Paused **/
protected void onPause() {
super.onPause();
locationManager.removeUpdates(this);
} // end onPause method
/** Create webView and JavaScript Interface **/
private void openBrowser(){
// Create webView and assign to web_view item
webView = (WebView) findViewById(R.id.web_view);
// JavaScript is off by default, enabling JavaScript
webView.getSettings().setJavaScriptEnabled(true);
// Enable zoom controls if supported by hardware
webView.getSettings().setBuiltInZoomControls(true);
// Create and set WebViewClient subclass for rendering
webView.setWebViewClient(new WebViewClient());
// Add Java to JavaScript Interface and call it 'android' for access.
webView.addJavascriptInterface(new JavaScriptInterface(), "android");
// Wait for the page to load then send the location information
webView.setWebViewClient(new WebViewClient());
// Load map.html page with webView
webView.loadUrl(getURL());
} // end Browser method
// Method to set/return URL for map page source
private String getURL() {
final String url = "file:///android_asset/map.html";
return url;
} // end getURL method
/** Retrieve current coordinates from GPS
* To save battery on the device the location update time has been increased. **/
private void getLocation() {
// Android GPS Manager
locationManager =
(LocationManager)getSystemService(Context.LOCATION_SERVICE);
// Application criteria for selection location provider
Criteria criteria = new Criteria();
// Set the accuracy requirement
criteria.setAccuracy(Criteria.ACCURACY_FINE);
// Get location data from best source
String provider = locationManager.getBestProvider(criteria,true);
// Get updates of current location
locationManager.requestLocationUpdates(provider, 2000, 1, this);
// Pass location data mostRecentLocation for JavaScript Interface
mostRecentLocation = locationManager.getLastKnownLocation(provider);
} // end getLocation method
/** Required methods when using LocationListener
* Referenced from Android API **/
@Override
public void onProviderDisabled(String provider) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onLocationChanged(Location location) {
mostRecentLocation = location;
}
/** End required methods when using LocationListener **/
} // End Browser.class Activity