Android Widget OnClick Example
Open link in browser after user do click on widget area:
private Context _context;
@Override
public void onStart(Intent intent, int startId) {
_context = this;
String definePage ="//old.chmi.cz/meteo/rad/rad_data.php";
Intent defineIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse(definePage));
PendingIntent pendingIntent = PendingIntent.getActivity(_context,
0 /* no requestCode */, defineIntent, 0 /* no flags */);
updateViews.setOnClickPendingIntent(R.id.widget, pendingIntent);
396LW NO topic_id
AD
Další témata ....(Topics)
Try each step separately:
- Restart Eclipse
- Clean project and rebuild
- Create a new project and try it if the problem persists, if no move copy project to other folder, delete project from workspace , create new project same name and copy java, xml etc. files to new project
- Close Eclipse, backup folder c:\Users\myName\workspace\.metadata and delete it. Restart Eclipse try again import project to workspace
- Re-installing the Android Developer Tools
- Re-installing Eclipse - rename old folder with Android to Android_old, create new folder C:\Program Files\Android and copy new Eclipse with sdk into new folder
- Created a new project importing from the file system
- Created a new project from subversion
If the app have transparent menu and you do not want this,
try delete @style/AppTheme in application tag in AndroidManifest.xml
and try run module - project. If menu is not transparent , maybe it caused
Or try set values\styles.xml into basic Theme
try delete @style/AppTheme in application tag in AndroidManifest.xml
and try run module - project. If menu is not transparent , maybe it caused
<application
android:allowBackup="true"
android:icon="@drawable/dicts_ico"
android:label="@string/app_name"
android:theme="@style/AppTheme" // delete this row - run app - try menu
>
Or try set values\styles.xml into basic Theme
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Black">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
Use this code for example in some method or function
// public Object getSystemService (String name)
// Return the handle to a system-level service by name.
// The class of the returned object varies by the requested name.
InputMethodManager inputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
//public boolean hideSoftInputFromWindow (IBinder windowToken, int flags)
//EditText myEdit = (EditText)findViewById(R.id.idEditText);
inputMethodManager .hideSoftInputFromWindow(myEdit.getWindowToken(), 0);
Create file restartADB.bat in folder
c:\Program Files\Android\android-sdk-windows\platform-tools\
Write into restartADB.bat this code:
Save restartADB.bat file.
If you want restart adb.exe server, run restartADB.bat by double click on icon.
Next example:
[caption id="attachment_778" align="alignleft" width="300" caption="ADB server restart by command line"][/caption]
Try restart ADB if this or similar errors:
Emulator] emulator: emulator window was out of view and was recentred
c:\Program Files\Android\android-sdk-windows\platform-tools\
Write into restartADB.bat this code:
adb kill-server && adb start-server
pause
Save restartADB.bat file.
If you want restart adb.exe server, run restartADB.bat by double click on icon.
Next example:
- Open Total Commander
- Open folder with adb.exe usually in
c:\Program Files\Android\android-sdk-windows\platform-tools\ - Put into command line command: adb kill-server && adb start-server and press Enter
[caption id="attachment_778" align="alignleft" width="300" caption="ADB server restart by command line"][/caption]
Try restart ADB if this or similar errors:
Emulator] emulator: emulator window was out of view and was recentred
The Android WebView changing the height according to text size.
If you need to change the height to a minimum try this source:
If you need to change the height to a minimum try this source:
//public void loadDataWithBaseURL (String baseUrl, String data, String mimeType, String encoding, String historyUrl)
WebView _webView; // findById(.....
String entryContent = "";
_webView.loadDataWithBaseURL(
"blabol",// javascript i styly
entryContent, null,
"utf-8", null
);
Editace: 2013-07-01 12:29:20
Počet článků v kategorii: 396
Url:android-widget-onclick-example